Understand on user input actions
The script actions that you define in the on user input event will be executed whenever the field value is added or modified by the user. It is used to improve the usability of a form by validating field data even before it is submitted or display other field values based on the value specified in this field.
Let's assume you have an Order Management application that is used to run your business. There is an in-house Bulk Order form that facilitates bulk orders. This form includes product details and the required quantity for each product. The application has another form for Stock Details which includes product related information and the quantity available (In Stock field) with regard to each product. When the user gives a value in the Quantity field, you need to run a workflow to check the records in Stock Details form to confirm if the value entered in the Quantity field is less than or equal to the value in the In Stock field in the Stock Details form. You can write a script that if the value in Quantity field of the Bulk Order form is greater than the value of the In Stock field in the Stock Details form, an error message needs to be displayed stating that only n number of items of this product is available.
For instance, the user enters the value of Quantity field as 100 in the Bulk Order form. At that point the workflow is run to check the records in Stock Details form. The value in the In Stock field is 60. An error message is displayed stating, "There are only 60 items available. Please enter a value lesser than or equal to the number of items available in stock." This prompts the user to reconsider the requirement without have to submit the form.