About functions in Enhancement Engine
In Enhancement Engine, JavaScript functions are the logic behind the transformation of label data.
You write functions to modify label requests entering EPP from an input agent. The functions change values in the label requests to transform the label data. Transformation to label data can include such things as adding additional data fields to the label, changing the label format, changing the label quantity, adding hazard warnings, etc.
You associate each function with a test input, which is the label request in the form of an .xml file. The .xml file contains the variables to which the function logic is applied. Refer to About test inputs. After you create and test your functions, you add them to a program. Refer to About programs.
A function in Enhancement Engine behaves like any JavaScript function; however, it is important to note the following:
-
Each function must contain a run command.
-
A function cannot have a System.exit command in it.
-
All JavaScript must comply with the ES5 standard or a previous standard.
Enhancement Engine provides commands you can include in the functions you write. These commands are not part of the usual javascript set, and they include printLabels, sendMail, newEmailMessage, newSqlType, newStoredProcedure, newDate, and newBoolean.
Additional functions are included in a set of provided sample functions. Refer to About sample functions.
Create a function
To utilize Enhancement Engine, you create JavaScript functions that you add to programs. The programs enhance label output with the data transformation you specify in the functions.
-
The .xml file you will select as the test input must have already been created.
-
Note that the name of the .xml file, the name of the program to which you plan to add the function, and the name of the Label Template in Label Designer will all need to match.
To create a function, complete the following steps in EPP.
-
Go to Develop > Enhancement Engine.
-
Under Function, in the Development folder, right-click and select New Function.Step InformationNote:You can create a new folder.Note:You can import a function. You can also copy and edit an existing function, including any from the Samples folder.
-
Enter a name for the function, and select OK.
-
Write a JavaScript function.Step InformationNote:In Enhancement Engine, each function must contain a run command. A function cannot have a System.exit command in it. All JavaScript must comply with the ES5 standard or a previous standard.
-
To test your function:Select a data file from the list.Select Test.To ensure the function ran successfully, review the data and the results on the following tabs. Output: Shows data about the test, such as test status and test length. Also contains a copy of the Input Data, the Input Label, and the Output Labels.Input Data: Shows a copy of the file used as the test input.Input Label: Shows the label data prior to your testing the function.Output Labels: Shows the label data changes applied by the function.Raw Output: Shows the label data changes applied by the function.
-
To save the function, select Apply. To save the function and close the window, select OK.
About sample functions
Enhancement Engine includes sets of sample functions you can copy into another folder and then edit, test, and include in the programs you create.
Sample functions save you time by providing templates for specific actions that you can associate with your own labels. These functions include comments. Each function also includes a run command, because this is a requirement of Enhancement Engine functions.
For example, the Samples folder contains a FormattoLabelName function that shows how to do for loops and if statements as well as use multiple functions.
Loading...
There was a problem loading this topic