Dynamic form validation with action center

Hi all ,
Can I pass a dynamic value to the form to use it in form validation (as maximum and minimum values ) please note that I want to use it in task form in action center not with the local form .

Yes, you can use the Collection property to do this.
The variables will automatically appear as components and you can use the variable names to reference these components on the form.

Thanks @codenameCata
Is that working with an action center ? I am using collection property , but I can’t add scripts or using components variable when I work with an action center , could you please show me where you setup the validation ?

Let’s say that we have a date component that should be less than another date (that I passed it to collection property) … How can I use this variable in the validation tab or conditional tab ?

If you have control over the two dates (or any data in your case) before passing them to the form, you could do all the decision making using standard UiPath activities or Invoke Code instead of trying to run conditions in the form.
You could send a boolean flag, based on which you can control the visibility of the button(s).

If you want to change the visibility on values that change at runtime due to user’s input (for example “From date must not be AFTER To Date” in case of a booking form) then you may need to look at form scripting, using Javascript or Lodash.

I hope this helps.

I already do that but I want to make a dynamic validation while the user changes the input , unfortunately scripts doesn’t work with the action center due to security issues .
Thanks anyway .

1 Like

Basic JavaScript expressions are now supported in Actions forms. Please check out this post New Action Center on Automation Cloud is GA now

“From date must not be AFTER To Date” in case of a booking form) then you may need to look at form scripting, using Javascript or Lodash.

I have this exact requirement. I have 2 date pickers in my Forms Designer, one for Start Date, and another for End Date. I would like to validate that the Start Date is not after the End Date but I do not see such a feature in the Simple Condition section of the Conditional tab.

I have just solved it but in a slightly different way. I can compare the 2 dates and make the Submit button disappear when there is an invalid selection.

For the benefit of anyone facing the same issue as me, here’s how I solved it.

This is how my Form Designer looks like:

The Javascript code in the Conditional tab of the configuration page of the Submit button:

Take note, to refer to the value of other elements in the JavaScript code, you need to add a “data.” followed by the FieldKey name as I have done in my if condition. The enddate and startdate are the FieldKey names of my Start Date and End Date elements.

The script will hide the Submit button if the End Date value is less than the Start Date value.

Here is the workflow as well (remember to install the UiPath.Forms.Activities package).
UiPathFormsDesigner_SelectAndCompareDates.xaml (13.3 KB)


1 Like