Frequently Asked Questions

Feb 20, 2024 - 11:10pm

 [F] Frequently Asked Questions  / Operational Questions  / Macros and Templates  / WCJS (Server Side JavaScript)  /

How to set Path and User Variables?

Rate This FAQ
 (Not yet rated)

Created On: 5 Jun 2002 10:26 am
Last Edited: 5 Jun 2002 10:26 am

Question Printer Friendly

Setting path and user variables - the difference between WCTL and WCJS


In WCTL, the way
  you set a path variable is to first make sure the current location is correct
  by using setPath. Then you use the path.variableName syntax to
  set the value. For example:

%% setPath (".ee652c")
%% set path.month "December" %%
%% setPath %%

In WCJS you would
  first lookup the object with the Node.lookup() method and then set a
  custom property for the object. For example:

var thisNode
    = Node.lookup(".ee652c");
thisNode.month = "December";

Note that with
  WCTL it is suggested to use %% setPath %% after you are finished to make sure
  you are back at the original location. However with WCJS you can directly modify
  objects. There is no need to "change your location".

This works the
  same way for user variables. In fact it is much easier to set user variables
  in WCJS. You just do a user lookup using the User.lookup() method and
  then set whatever you want, as in:

var thisUser
    = User.lookup("doug"); = "Suginami";