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

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.

Jitendra Diwak1
Kilo Sage

Hi @virajsapte99,

 

Could you please make the correction in line no.3 as g_form.getValue('category'); instead of g_form.category=='category'; Even after correcting this if it does not work then copy the code and paste in script in Execute if false in below. Please try this and hope this will work.

 

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

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

swathisarang98
Giga Sage
Giga Sage

Hi @virajsapte99 ,

 

I can see that you have created a onchange client script and you are trying the same script in onload ui policy which might not work once you change the Category value so if you want your ui policy to work on onchange aswell then uncheck the Field called OnLoad in ui policy then it will work as onchange of field, let me know if this works or not.

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang