Multiple Field Changes

Liz Abraham
Tera Contributor

Hello,

 

I have a requirement where I have 20 fields on a form and if I change the value of any of fields , I have to set a justification field to mandatory  and set it to focus and have the user provide a reason before saving the form. 

 

I used a business rule to check if the field changes and display a message but the mandatory or focus part i  can't do it in a BR. Any suggestions?

10 REPLIES 10

Vishal Birajdar
Giga Sage

Hi @Liz Abraham 

 

 

Have you tried this KB article for focus ...

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0694100

 

**Note : The solution is not provided by ServiceNow 

 

You can use client ui policy like below :

 

Use OR conditions to validate 

VishalBirajdar_0-1706331927714.png

 

& In script section write below code :

 

g_form.setMandatory('<Field Name>',true);
g_form.getControl('<Field name>').focus();

 

Here I tried for description field

VishalBirajdar_1-1706332023498.png

 

 

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Yes, I did,and didn't work.

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Liz Abraham 

 

You can use UI policy. 

 

condition

field changes to ....

 

UI action

Make rest field mandatory.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

UI Policy conditions do not support field changes… and for good reason:

This would also fundamentally break to concept of UI policies - how should mandatory and visible states be handled when a field changes? This would result in totally unclear states. It would also neglect the „Run if false“ idea…

Liz Abraham
Tera Contributor

Thanks everyone, for your feedback. I actually tried something and I am yet to fully  test it , but what i did was create a BR that checks to see if the field changes using the conditions and a script to just say that a justification is required. But i created another field that set the field Value to yes if any of the 20 fields change and then using that field, i created  a UI policy to check to see if that field value is yes to set the justification field to mandatory. 

 

Will have to test it , may not be the best approach.