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.

Call a UI Action from a Client Script to open a Change

RWeathersby1
Kilo Explorer

**I'm sure this has been done, before just can't find anything on the forum so I'm asking.**

I am trying to call a UI Action from a Client Script. I have a onChange Client Script running from the Incident table that if the 'confirm' value is True I'd like to automatically open a related Change record. But it's not working...thoughts?

Here's the code that I wrote that's not working.

function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '7' && !isLoading && g_form.getValue('rfc')=='') {
var rfc = g_form.getReference('rfc');
var answer = confirm('Was this Incident resolved by a Change? If yes press OK to create a Change Record. If No press Cancel.')
//force the Resolved by Change to Mandatory if OK
if (answer == true)
gsftSubmit(null, g_form.getFormElement('name'), 'Create Change');
else
g_form.setMandatory('rfc', false);
return;
}
}

13 REPLIES 13

Was the change record created?


It does not create the change record or relate the Incident to the change. It just goes back to the Incident queue.


Amit107
ServiceNow Employee
ServiceNow Employee

Hello Roderick



Did you get this sorted ? I am trying the same requirement and getting the same result as you mentioned. It goes back to the incident list.



Cheers


Amit


Jim Coyne
Kilo Patron

You might want to try:
- adding the code into one of the demo instances so we can see exactly how you have things setup
- adding some gs.log() calls in the UI Action to see if it is even being called/run
- should not affect anything, but your "var rfc = g_form.getReference('rfc');" call serves no purpose and is making a server call for nothing