Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set field value true if the caller field has a particular person

Community Alums
Not applicable

On an interaction, I have a field name 'u_external_user'. It is a checkbox (True/False).

I want to toggle this field True if the Opened for field 'opened_for' is a user named External User. I believe a client script will be the best way to do this but need advice on this and code if anyone can help.

1 ACCEPTED SOLUTION

Shamma Negi
Kilo Sage
Kilo Sage

if(g_form.getValue("opened_for") == "sys id of the external user)

{

g_form.setValue("<external_user_checkbox" , true);

}

else

 

{

g_form.setValue("<external_user_checkbox" , false);

}

Regards,Shamma Negi

View solution in original post

23 REPLIES 23

Community Alums
Not applicable

In the UI Policy, would I use a script to set the toggle to true?

No. 

 

In UI policy action, use that field and make 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]

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

Hi @Community Alums 

 

Sorry for confusion. I thought you want to make field mandatory but you want to set the value as True , so in this case client script is best option.

 

You can check the script shared by @Anurag Tripathi  and do this on client script onload.

 

 

LearnNGrowAtul_0-1702557562735.png

 

*************************************************************************************************************
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]

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

Shamma Negi
Kilo Sage
Kilo Sage

if(g_form.getValue("opened_for") == "sys id of the external user)

{

g_form.setValue("<external_user_checkbox" , true);

}

else

 

{

g_form.setValue("<external_user_checkbox" , false);

}

Regards,Shamma Negi