The CreatorCon Call for Content is officially open! Get started here.

Change record number

Parag1
Tera Contributor

I want change record number using background script how can i do it ?

I used this script help me to find solution.I tried with this code but its inserting new record.

var gr = new GlideRecord ('incident_task');

gr.addQuery('sys_id','cc79b1aa2fa23010466e70682799b6f6');

gr.query();

gr.number= "TASK0020745");

gr.setWorkflow(false);

gr.update();

1 ACCEPTED SOLUTION

Value is now corrected. This is the right code

var gr = new GlideRecord ('incident_task');

gr.get('cc79b1aa2fa23010466e70682799b6f6');



gr.setValue('number','TASK0020745');

gr.setWorkflow(false);

gr.update();

Please Mark Correct AND Helpful. Thanks


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

View solution in original post

3 REPLIES 3

Martin Ivanov
Giga Sage
Giga Sage

I wouldn't advice you to do so, but if you still want, try the following

var gr = new GlideRecord ('incident_task');

gr.get('cc79b1aa2fa23010466e70682799b6f6');



gr.setValue('number','TASK0020745');

gr.setWorkflow(false);

gr.update();

Please Mark Correct AND Helpful. Thanks!


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Have a typo. 🙂

var gr = new GlideRecord ('incident_task');
gr.get('cc79b1aa2fa23010466e70682799b6f6');
gr.setValue('number',TASK0020745');
gr.setWorkflow(false);
gr.update();

Value is now corrected. This is the right code

var gr = new GlideRecord ('incident_task');

gr.get('cc79b1aa2fa23010466e70682799b6f6');



gr.setValue('number','TASK0020745');

gr.setWorkflow(false);

gr.update();

Please Mark Correct AND Helpful. Thanks


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024