Easiest way to update multiple records from a table

mitzaka
Mega Guru

Hi SNC,

What will be the quickest way to go through all the records in a table and update a certain field in all of those records?

1 ACCEPTED SOLUTION

script based on the info you have provided ...



var gr = new GlideRecord('u_org_admin');


gr.query();


while(gr.next())


{


var referenceRecord = gr.u_org_admin.getRefRecord();


referenceRecord.u_is_org_admin = true;


referenceRecord.setForceUpdate(true);


referenceRecord.setWorkflow(false);


referenceRecord.update();


}


View solution in original post

12 REPLIES 12

Absolutely will take attention into it:)


script based on the info you have provided ...



var gr = new GlideRecord('u_org_admin');


gr.query();


while(gr.next())


{


var referenceRecord = gr.u_org_admin.getRefRecord();


referenceRecord.u_is_org_admin = true;


referenceRecord.setForceUpdate(true);


referenceRecord.setWorkflow(false);


referenceRecord.update();


}


lasse3
Mega Guru

Just wanted to add that you can use the updateMultiple as well. Here is an example from the wiki.



// update the state of all active incidents to 4 - "Awaiting User Info"


var gr = new GlideRecord('incident')


gr.addQuery('active', true);


gr.query();


gr.setValue('state',   4);


gr.updateMultiple();