- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 04:09 AM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 05:04 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 04:45 AM
Hi Dimitar,
Either run a background script or create an on demand scheduled job for this . Use setWorkflow(false) to make this query more optimum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 05:00 AM
My table is called "u_org_admin" and the value I am trying to update is a true/false field on User form, named "u_is_org_admin". In the u_org_admin table I have a reference field called 'u_org_admin'.
I am trying with a background script of:
var gr = new GlideRecord('u_org_admin');
gr.addQuery('u_org_admin'); // because I want to get this field from all records in the table
gr.query();
while(gr.next())
{
gr.u_org_admin.u_is_org_admin = true; //here is where I try to set the value of the field
gr.setForceUpdate(true);
gr.setWorkflow(false);
gr.update();
}
However, it does not work, my values are still false.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 05:04 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 05:09 AM
You're a monster idude:) Agan that refRecord ,,,,,Kalaiarasan P Cheers!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 05:11 AM
You seriously need to learn this getRefRecord