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 to true on incident form for specific user

Community Alums
Not applicable

We have a user that is named External User in our user table. I would like to toggle a custom field 'u_external_user' field true if the user is selected. I am using an onChange client script but need some help with the code.

3 REPLIES 3

Swapna Abburi
Mega Sage
Mega Sage

@Community Alums 

You can use onchange client script if you are looking to update u_external_user flag on the form itself.

Sample onchange client script using getReference method with a callback function.

 

var caller = g_form.getReference('caller_id', setExternalFlag);
function setExternalFlag(caller) {
   if (caller.name=="External User")
       g_form.setValue('u_external_user', true);
}

 

Or you can use onbefore business rule and update the flag using Set fields. Business rule will update the flag only after record is saved.

 

Community Alums
Not applicable

When I use this script (I had a similar script earlier) this is the error I get:

 

ShannonPearson_0-1703029169609.png

 

Hi @Community Alums   the recommended method looks right, please share your client script - will make it easier to debug,.

--

Bala G