When you click an external link script button on a customized panel, the Customizer module prepares the script, executes it, then retrieves values from variables that are set to be returned to Sage 100.
You must distinguish between the script which is created by the user, and the full script which the Customizer module passes to the MS Script processor. Before executing the script, the Customizer module retrieves system variables, panel variables, and the user script to construct the full script. The Customizer module also adds remarks to the full script to distinguish each of its sections.
Before script execution:
Predefined variables from the current Sage 100 workspace are set up. (For example, a variable containing the current module’s accounting date is passed to the script processor as MAS_SCR_DTE="20021231".)For more information, see MS Script System Variables.
User-selected variables from the current Sage 100 panel are gathered and their values are determined (for example, ML_BALANCE=5523.75). Dates are formatted as YYYYMMDD. Check box values are passed as a Y or an N.
The script file is opened, and its contents are read and analyzed.
If the MAS_SCR_DBG variable is set to 1 in the script, a window appears displaying the full script. This is done before the script is run so that you can view exactly what is being passed to the script control. Click Stop to terminate script processing.
During script execution:
The MS Script Control processor item is created.
The script language is set.
The ALLOWUI property is set to 1 if the script is running on a client, or 0 if the script is running on the host.
The full script, containing variables and user script code prepared in the prior step, is passed to the script control.
If an error occurs during script execution, the Customizer module displays the error code and error description (script language dependent), and the line and column in the script where the error occurred. If the error text is available, it also displays (this is normally the text of the line in which the error occurred, but is not always available). Clicking Info in the error dialog box opens a window that displays the script with line numbers, which can be used for debugging.
Note Dates set in the user script must be in YYYYMMDD format. Check boxes set in the user script must be set to Y or N.
After script execution:
If the MAS_SCR_DBG variable is set to 1 in the user script, a window appears showing the variables being returned by the script. This is done after the script runs so the user can view what is being returned to Sage 100.
The MAS_SCR_MSG string variable is evaluated. If this variable is set during script execution, a dialog box containing its text displays. This allows the script to pass either a final error or success message to Sage 100, rather than displaying such a message in the script.
The MAS_SCR_ERR numeric variable is evaluated. If set to 1 during script execution, script processing terminates and control returns to Sage 100. This causes the script to instruct the Customizer module to not retrieve variable values or perform other post-script logic.
Each user-defined variable specified to return from the script is evaluated. Dates are in YYYYMMDD format. RETURN_FLG is set to 1 so that the Nomads panel refreshes, and CHANGE_FLG is incremented by 1.
If the Nomads control associated with a return variable is on the current panel and is locked or disabled, its value is not changed.
If the Nomads control associated with a return variable has on-select PERFORM or EXECUTE logic, it is automatically executed by the Customizer module.
The MAS_SCR_PFM string variable is evaluated. If it is not null, the Customizer module attempts to PERFORM the program before returning control to Nomads.