Espresso Scripts
The Espresso Application Builder program includes a script editor that lets you add scripting to an Espresso component. This allows you to build additional business logic into Espresso.
Exploring
Things you can do in this program includes:
- Execute a workflow when a sales order is created.
- Change the color of an account balance when it reaches a certain amount.
- Prevent an operator from adding a sales order line against a specific warehouse.
A script can be added against a component (when the component is loaded or refreshed) or against a particular field on the component (when it gains focus, or after it is changed).
Solving
The following scenario outlines how to disable saving cost modification on Warehouse FG.
-
Open the Espresso Application Builder program.
-
Expand the Standard folder in the Applications pane.
-
Navigate to and select the Cost Modifications application.
-
Select to Copy the application.
-
Specify the Target application level required.
-
Select Save and Exit.
A new entry/folder is created depending on the Target application level specified.
-
Expand the folder and select the copied Cost Modifications application.
-
Select the Entry Form Component type (Description: Cost Modifications).
-
Select the Edit Script option.
-
Ensure that the Event field is set to Before save.
-
Enter the following code in the Script editor:
Copyif (GetDataBoundField('Warehouse') === 'FG')
{
ShowGlobalWarning('You cannot modify costs on stock in
Finished Goods warehouse'); cancelSaveEvent();
} -
Save and Close the script.
-
Login to SYSPRO Espresso to see the results:
-
Select Cost Modifications.
-
Enter the FG warehouse in the Warehouse code field.
-
Select Save Lines.
-
-
Open the Espresso Application Builder program.
-
Expand the Standard folder in the Applications pane.
-
Navigate to and select the Activity Entry application.
-
Select to Copy the application.
-
Specify the Target application level required.
-
Select Save and Exit.
A new entry/folder is created, depending on the Target application level specified.
-
Expand the folder and select the copied Activity Entry application.
-
Select the Entry Form Component type (Description: Activity Maintenance).
-
Select the Edit Script option.
-
Ensure that the Event field is set to On refresh.
-
Enter the following code in the Script editor:
GetDeviceLocation(function(data) { SetDataBoundField('UserField3', data.Latitude + ',' + data.Longitude); });
-
Save and Close the script.
-
Login to SYSPRO Espresso and select New Activity to see the results.
Copyright © 2021 SYSPRO PTY Ltd.