Field Value validation in UI Policies script

virajsapte99
Tera Contributor

Hi,

Recently, I tried to check values of a field in UI Policy script, but it didn't work while it works in Client script. I was wondering about this behavior. Can someone please help me understand this.

Attaching screenshot for reference

virajsapte99_0-1716146134109.png

virajsapte99_1-1716146158895.png

The same code works in client script

virajsapte99_2-1716146227546.png

 

1 ACCEPTED SOLUTION

Hi @virajsapte99 

 

You can do field value validation in UI Policy Scripts as well but if you want to do the validation in real-time without save, you need to make use of On-Change Client Script. If you want the validation to happen post save, you can make use of UI Policy Scripts. Refer below screenshot where I configured the UI policy as per your screenshots and it only fires when I change the category and save the record :

 

AmitVerma_0-1716268484549.png

 

AmitVerma_1-1716268518769.png

 

AmitVerma_2-1716268538616.png

 

AmitVerma_3-1716268557230.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

7 REPLIES 7

James Chun
Kilo Patron

Hi @virajsapte99,

 

Can you elaborate on what you mean by it's not working?

But from what I can see, line 3 of the UI Policy script looks incorrect.

It should be g_form.getValue('category') instead of g_form.category

 

Cheers

Amit Verma
Kilo Patron
Kilo Patron

Hi @virajsapte99 

 

I could see an error in your UI policy script on line 3. Could you please have a look on that ? It should be g_form.getValue('category');

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

virajsapte99
Tera Contributor

Hi @James Chun & @Amit Verma ,

Thank you for taking out time to respond. I have already fixed it but still it doesn't work. My concern is whether field value validation works in UI Policy scripts?

Hi @virajsapte99,

 

Can you elaborate on what you are trying to do and its purpose?

 

I guess you can do some data validation with UI Policy by throwing some error messages and/or clearing the values of the fields. But you won't be able to prevent a form submission.