Comment on page
Describes how Trayse Inventory uses Variables
Script variables are lower camel case, like field names. E.g.
Variables for primary and foreign keys are also like the field names. E.g.
The ID is capital and at the end of the string.
Calculations are often defined inside a script variable instead of the Set Field definition. This makes it easier to see the variable before setting the field when debugging.
Set Variable [ $tempPendingValue ; Value: ORDERLINE::qtyPending * -1 ]
Set Field [ ORDERLINE::qtyPending ; $tempPendingValue ]
Rather than this
Set Field [ ORDERLINE::qtyPending ; ORDERLINE::qtyPending * -1 ]
A handful of global variables are defined during the startup process. E.g.
The variables defined at startup are intended to remain for the duration of the session.
Global variables defined in other scripts are created when it is easier than passing a local variable through various subscripts. These global variables are managed in such a way that they are cleared after user. This usually occurs at the end of a script:
Set Variable [ $$warehouseID ; Value: "" ]
If a single variable is passed from one script to another, then the variable is listed as a parameter.
If multiple variables are passed, then those variables are defined in the script and packaged as a JSON object within another variable called $parameter. E.g.
Set Variable [ $itemID ; Value: ITEM::ID ]
Set Variable [ $sku ; Value: ITEM::sku ]
Set Variable [ $parameters ; JSONSetElement ( "" ; [ "itemID" ; $itemID ; JSONStirng ] ;[ "sku" ; $sku ; JSONStirng ] ]
Perform Script [ Specified: From list; "script name here (itemID, sku)" ; Parameter: $parameters ]
Receiving multiple variables is done in two steps:
- 1.Get the script parameter
- 2.Unpack the JSON element
Set Variable [ $parameters ; Value: Get ( ScriptParameter) ]
Set Variable [ $itemID ; Value: GetAsNumber (JSONGetElement ( $parameters ; "itemID" ]
Set Variable [ $sku ; Value: GetAsNumber (JSONGetElement ( $parameters ; "sku" ]
Set Variable [ $price ; Value: GetAsNumber (JSONGetElement ( $parameters ; "price" ]
Calculation variables occur in Let () statements and While () statements. These are prepended with an underscore. These variables are also indented by two spaces. E.g.
_today = Get ( CurrentDate ) ;
_thisMonth = Month ( _today )