Writing Formula Scripts 
Formula scripts for data collection use interpreted JavaScript as the scripting language.
You can use the findSingleParameter method with arguments as defined below:
findSingleParameter("parameter_name", "this" | "subassy", "item_name", "item_revision", "operation_name", "operation_revision", "resource_name", "last");
Note that you must enclose each argument in either double or single quotation marks.
Argument |
Description |
|---|---|
parameter_name |
The name of the parameter as it appears in the Parameter Name field in Data Collection Maintenance |
this | subassy |
Use one of these literals: this returns the current SFC number subassy returns the SFC number of a subassembly consumed by the current SFC number |
item_name |
The name of the material associated with the SFC number |
item_revision |
The version of the material associated with the SFC number |
operation_name |
The name of the operation where data was collected for the SFC number |
operation_revision |
The version of the operation where data was collected for the SFC number |
resource_name |
The name of the resource where data was collected for the SFC number |
last |
Required literal to end the argument |
Note that you cannot use mathematical symbols (+, -, *, /) in parameter names that are used in calculations.
The DC group DC1/A has one parameter, P1, of the Numeric type. DC1/A is attached to the operation OP1.
The DC group DC2/A has three parameters defined as follows:
Parameter Name |
Type |
|---|---|
P2 |
Numeric |
P3 |
Numeric |
PFORM |
Formula |
DC2/A is attached to the operation OP2.
In the Standard and Integrated PODs, the operator collects data at OP1 via the Data Collection plug-in (DC500). In the Rich POD, the operator collects data at OP1 via the Rich POD Data Collection plug-in (DC500_RICH). Using the following formula for PFORM, when the operator at OP2 enters data for P2 and P3, and saves the entries, the Data Collection plug-in calculates the sum of these two values as well as the saved value entered for P1 at OP1.
a=P2+P3;
b=findSingleParameter("P1", "this", "ITEM1", "*", "OP1", "A", "RES1", "last");
c=a+b;
exit(c);
Caution
When creating formulas, make sure that user input does not cause divide-by-zero errors.