Want to write a FIX script for updating a field

Sayan
Mega Contributor

I want to write a fix script for doing a bulk update in the indicator task table into a particular field.The table is IDT. The tasks are already closed, so the field is grayed out. Below is the code that I have written.

var gr = new GlideRecord('table name');
gr.addEncodedQuery('the query for the tasks that needs to be updated.');
gr.query();
while(gr.next()){
gr.fieldname = "the update";
gr.setWorkflow(false);
gr.update();
}

After I run the script I find that no changes has happened in the required field. It still shows blank.

Any help will be appreciated.

1 ACCEPTED SOLUTION

Hello Sayan,

I hope you are actually running the correct code. This below code will not work as is. you need to place right field names and right queries.

var gr = new GlideRecord('table name');
gr.addEncodedQuery('the query for the tasks that needs to be updated.');
gr.query();
while(gr.next()){
gr.fieldname = "32 digit sys_id that you need to update";
gr.setWorkflow(false);
gr.update();
}

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

View solution in original post

8 REPLIES 8

Swadesh Saraf2
Kilo Guru

Guys, I have seen this question around 6 times in last 1 hour. Please remove all these duplicate post and post it only once so that people can help you and you can get the answer quickly.

 

Thanks

asifnoor
Kilo Patron

Hi Sayan,

If its a reference field, then you need to mention the sys_id in that field. ARe you setting the sys_id correctly?

Is the code entering the while loop? check once.

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

Sayan
Mega Contributor

Yes its entering the while loop. Please be more specific with sys_id. a coding example will be more helpful.

Hello Sayan,

I hope you are actually running the correct code. This below code will not work as is. you need to place right field names and right queries.

var gr = new GlideRecord('table name');
gr.addEncodedQuery('the query for the tasks that needs to be updated.');
gr.query();
while(gr.next()){
gr.fieldname = "32 digit sys_id that you need to update";
gr.setWorkflow(false);
gr.update();
}

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP