Edit a Calculated Property for a Screen.
Your user account or group membership must have the following permissions to edit a Calculated Property for a Screen:
Screens: Edit Screens
Screens: View Screens
See the Screens permissions or ask your Administrator for assistance.
Avoid performance issues and follow best-use guidelines by following best practices.
Follow these steps to edit a Calculated Property for a Screen:
Open the Screen in which to add a Calculated Property. The Screen is in Design mode.
View the Calculated Properties for that Screen. The Computer Properties screen displays all Calculated Properties for this Screen.
Edit the following settings about the Calculated Property as necessary:
In the Property Name setting, edit the name of the Calculated Property. This Calculated Property name displays both in the Calculated Properties screen and in the JSON data model when previewing the Screen. Calculated Properties are case-sensitive. See Calculated Property Best Practices. This is a required setting.
In the Description setting, edit the description of the Calculated Property. This is a required setting.
Above the Formula setting, select one of the following ways to determine how the Calculated Property determines its value:
Screen control value:
Reference a Screen control's value by referencing that control's Variable Name setting to use it in a mathematical calculation. Example to calculate the total cost of a purchase: NetCost
+ ( NetCost
* (SalesTaxRate
/100)) when NetCost
and SalesTaxRate
are the Variable Name setting values for the two controls storing the net cost for a purchase prior to sales tax and the local sales tax rate, respectively.
Magic Variable value:
Reference a Magic Variable's value. ProcessMaker Platform uses a set of Magic Variables that become part of the JSON data model for all Requests. ProcessMaker Platform uses these Magic Variables to store user, Process, and Request related data for all Requests. During an in-progress Request, these Magic Variables are updated. An underscore (_
) character precedes all Magic Variables in the JSON data model. Example to get the ID for the user completing the current Task in that Request: _user.id
.
Follow these guidelines to reference Screen control or Magic Variable values:
Screen control value:
Reference a Screen control's value by referencing that control's Variable Value setting. Example: return this.FullName
when FullName
is the Variable Value setting value for the control to reference its value when the Calculated Property runs.
Magic Variable value:
Reference a Magic Variable's value as described above for mathematical calculations. Reference the Magic Variable after the this.
keyword when using JavaScript as the input method. Example: return this._user.fullname
to reference the user's full name from the in-progress Request. See Magic Variable Descriptions.
In the Formula setting, edit the mathematical calculation/JavaScript that determines the Calculated Property value. This is a required setting.
Click Save. The Property displays in the Calculated Properties screen. The following message displays: Property Saved.
Ensure to save your Screen. The Calculated Property is not edited until you save it. Doing so will save your work if your session expires.
Click the Edit iconfor the Calculated Property to edit. The Calculated Properties screen displays that Calculated Property's name, description, and how its value is determined.
Mathematical calculation: Click the Formula iconto enter the value, mathematical calculation, or formula that calculates the Calculated Property. The Formula icon is selected by default. Follow these guidelines to reference Screen control or Magic Variable values:
JavaScript:
Click the JavaScript iconto calculate the Calculated Property using valid JavaScript. By calculating the Calculated Property using JavaScript, you can reference the values for Screen controls and Magic Variables. Ensure to use valid JavaScript to calculate the Calculated Property by using a return
statement to return the result of an expression (the value). Furthermore, ensure to use the this.
JavaScript keyword preceding the Screen control/Magic Variable reference. See the examples below.