Page History
...
In an INVOKE script you can define and check for the existence of optional parameters like this:
/* Conceptually this script's behavior is controlled by 2 parameters which may or may not be passed to it */
var Parameter1 = "parameter default value";
var Parameter2 = "parameter default value";
/* If either parameter has been passed in the objGlobal object then override the default behavior. */
/* Note the destruction of the optional parameters. This is so they do not hang around to interfere */
/* with later executions of this script. They are created, passed into the script and then destroyed. */
if (objGlobal.optParameter1 != null) { Parameter1 = objGlobal.optParameter1; objGlobal.optParameter1 = null; }
if (objGlobal.optParameter2 != null) { Parameter2 = objGlobal.optParameter2; objGlobal.optParameter2 = null; }
/* Now use the values in Parameter1 and Parameter 2 to control how this script behaves */
< etc >
< etc >
As a specific example, imagine an INVOKE script that by default displayed the current customer from the instance list. However, some other scripts reuse it to display a specific customer, which may or may not be in the instance list.
You could handle this situation like this:
/* By default this script displays the current customer from the instance list, so get the customer number */
var RequestedCustomer = objListManager.AKey1[0];
/* If the caller has supplied a specific customer number use it instead (making sure to destroy the optional parameter) */
if (objGlobal.optRequestedCustomer != null)
{
RequestedCustomer = objGlobal.optRequestedCustomer;
objGlobal.optRequestedCustomer = null;
}
/* Now display the details of the customer identified in RequestedCustomer */
< etc >
< etc >
In a script that wants to display a specific customer number you could do something like this:
/* Save the changes and (re)display this customer */
case case KeyEnter:
{
var var CustomerNumber = GETVALUE("CustNo"); /* Get the updated customer number from the current screen */
SENDKEY SENDKEY(KeyEnter); /* Update the current screen details */
objGlobal.optRequestedCustomer = CustomerNumber; /* Set up the specific customer number you want (re)displayed */
NAVIGATE_TO_DESTINATION("uShowCustomerDetails"); /* Redisplay the customer by executing the destination script again */
}
break;