ProcessMaker API Documentation
Script Central

Add a Calculated Property for a Screen

Add a Calculated Property to a ProcessMaker Screen.

Add a Calculated Property

Permissions Required

Your ProcessMaker user account or group membership must have the following permissions to add a Calculated Property for a ProcessMaker Screen unless your user account has the Make this user a Super Admin setting selected:

  • Screens: Edit Screens

  • Screens: View Screens

See the ProcessMaker Screens permissions or ask your ProcessMaker Administrator for assistance.

Topic Update

This topic is updated for ProcessMaker version 4.0.3. See the Release Notes.

Follow these steps to add a Calculated Property for a ProcessMaker Screen:

  1. Open the ProcessMaker Screen in which to add a Calculated Property. The ProcessMaker Screen is in Design mode.

  2. View the Calculated Properties for that ProcessMaker Screen. The Calculated Properties screen displays all Calculated Properties configured for this ProcessMaker Screen. If no Calculated Properties have been configured for this ProcessMaker Screen, No Data Available displays.

  3. Click the +Property button. The Calculated Properties screen displays settings to configure a Property.

  4. In the Property Name setting, enter 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 ProcessMaker Screen. This is a required setting.

  5. In the Description setting, enter the description of the Calculated Property. This is a required setting.

  6. Above the Formula setting, select one of the following ways to determine how the Calculated Property determines its value:

    • 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.

    • 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 ProcessMaker Screen controls and ProcessMaker 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 ProcessMaker Screen control/Magic Variable reference. See the examples below.

      Follow these guidelines to reference ProcessMaker Screen control or Magic Variable values:

      • Screen control value:

        Reference a ProcessMaker 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 ProcessMaker Magic Variable's value. ProcessMaker uses a set of Magic Variables that become part of the JSON data model for all Requests. ProcessMaker uses these Magic Variables to store ProcessMaker user, Process, and Request related data for all Requests. During an in-progress Request, these ProcessMaker Magic Variables are updated. All ProcessMaker Magic Variables are preceded by an underscore (_) character in the JSON data model. Reference the ProcessMaker Magic Variable after the this. keyword. Example: return this._user.fullname to reference the ProcessMaker user's full name from the in-progress Request. See Magic Variable Descriptions. Note that there is no ProcessMaker Magic Variable that stores the ProcessMaker user that starts a Request (known as the requester). To address this, use a Calculated Property to reference the _user.fullname Magic Variable's value in the ProcessMaker Screen referenced in the first Task element of a Process; since many Processes are designed such that the requester is the ProcessMaker user assigned the first Task in a Request, this is a helpful way of storing who the requester is. This Calculated Property stores this Magic Variable's value, which you may reference elsewhere.

  7. In the Formula setting, enter the mathematical calculation/JavaScript that determines the Calculated Property value. This is a required setting.

  8. Click Save. The Property displays in the Calculated Properties screen. The following message displays: Property Saved.

Ensure to save your ProcessMaker Screen. The Calculated Property is not added to your ProcessMaker Screen until you save it. Doing so will save your work if that your session expires.

Calculated Properties screen with a new Calculated Property

Related Topics