UI Action to Clear Field

Sam Ogden
Tera Guru

Hi All,

We have a 'Cancel Change' UI action on our change request form.   This currently has the following code:

find_real_file.png

I was looking to add something like the below code to this, so that when the change is cancelled it finds any records in the task_ci table that have the same change number and then clears the xml field:

var pc = new GlideRecord('task_ci');
pc.addQuery('task',current.number);
pc.query();
while (pc.next())
  {
    pc.xml = "";
  }

})(current, previous);

However this has not worked and the xml field does not clear.   Any suggestions as to where I have gone wrong will be greatly appreciated.

Thanks

Sam

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Sam,



You dont have pc.update() to update


have like this :



var pc = new GlideRecord('task_ci');


pc.addQuery('task',current.sys_id);


pc.query();


while (pc.next())


  {


    pc.xml = "";


pc.update();


  }


View solution in original post

2 REPLIES 2

manikorada
ServiceNow Employee
ServiceNow Employee

Sam,



You dont have pc.update() to update


have like this :



var pc = new GlideRecord('task_ci');


pc.addQuery('task',current.sys_id);


pc.query();


while (pc.next())


  {


    pc.xml = "";


pc.update();


  }


Hi Mani,



Thanks for the above.   I knew I would be missing something straightforward.   Still learning the scripting side!


Also I was using current number rather than current.sys_id.



Working great now,



Thanks for your help.