activities
latest
false
UiPath logo, featuring letters U and I in white

Workflow Activities

Last updated Dec 20, 2024

Summing up two text fields dynamically

Trigger type: JavaScript Action type: Value

This advanced logic sums up two text fields, based on the condition that the user interacts with the corresponding text fields.

At runtime, if the business user interacts with text fields A and B, the Total field gets automatically filled in, displaying the sum of A and B.
  1. Open or create a Form file in Studio.
  2. Add three Text Field components into your form.
  3. Name two of the text field components as A and B, and name the third one as Total. Pay attention to their Property Names, as you use those in your advanced logic.
    Optionally, you can set the Total text field component as Disabled, so business users cannot interact with it.
  4. Go to the Logic tab of the Total field component.
  5. Add a logic and name it "dynamic sum".
  6. Select the Javascript trigger type, and enter the following script in the Text Area section:
    result = true;
    return result;result = true;
    return result;
    The above snippet detects if there are any changes in the text fields, i.e., the user interacts with the text fields, and triggers the action to sum up the fields.
  7. Add an action and name it "a+b".
  8. Select the Value action type, and enter the following script in the Value (Javascript) section:
    result = (+data.a) + (+data.b);
    return result;result = (+data.a) + (+data.b);
    return result;
    Replace a and b with the field keys values of the text field components.
  9. Save the action and the logic.
  10. Save the component.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.