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.

Alert message onChange Client Script

javis
Giga Expert

Hi all,

I could use some help with what I'm trying to accomplish. I'm trying to create an alert message when the disposition is set to cancelled. Ideally I would like to have the alert message show onChange but I would like a cancel option on the alert message and then have the values return back to what they were before.

Here is my code so far:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

  if (isLoading || newValue === '') {

  return;

  }

  //Alert message if dispostion changes

  if (oldValue != newValue)

  alert('You changed the disposition to ' + newValue + '. Cancelling this Demand item will cancel all associated tasks as well. Are you sure you want to continue?');

  g_form.setValue('cancelled', oldValue);

}

This is a client script, onChange

Thank you in advance!

5 REPLIES 5

Thanks Ujjawal!



I'm having trouble returning the old values when cancel is selected. I need to be able to return the previous value of the state and sometimes the disposition.