- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 11:42 AM
HI,
The below is my query for a table to update record via fix script or background script.
var gr = new GlideRecord('fm_expense_line');
gr.query();
while(gr.next())
{
var currentDesc = gr.getValue('short_description');
gr.setValue('short_description',currentDesc+' ');
gr.update();
gr.setForceUpdate('true');
}
now since in the table number of record is more then 100K hence I want to run the query for specific date range like then How I can add the same in the code.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 11:47 AM
Hello ARNAB,
Do you want to know a secret? 🙂
If you are able to filter that data in the list view, then this is piece of cake!!
Check this example here: I will filter in the incident table, active records with status New and In Progress:
Then, on top, I will see the filter query:
Now, if I right click on the end of the filter query (in my case the "state in (New, In Progress)"), I will see three options:
From there, you select "Copy query".
Then, go to your script and use the addEncodedQuery method
var gr = new GlideRecord('fm_expense_line');
gr.addEncodedQuery(<PASTE_YOUR_QUERY_HERE>);
gr.query();
while(gr.next())
{
var currentDesc = gr.getValue('short_description');
gr.setValue('short_description',currentDesc+' ');
gr.update();
gr.setForceUpdate('true');
}
Hope this helps!!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 11:47 AM
Hello ARNAB,
Do you want to know a secret? 🙂
If you are able to filter that data in the list view, then this is piece of cake!!
Check this example here: I will filter in the incident table, active records with status New and In Progress:
Then, on top, I will see the filter query:
Now, if I right click on the end of the filter query (in my case the "state in (New, In Progress)"), I will see three options:
From there, you select "Copy query".
Then, go to your script and use the addEncodedQuery method
var gr = new GlideRecord('fm_expense_line');
gr.addEncodedQuery(<PASTE_YOUR_QUERY_HERE>);
gr.query();
while(gr.next())
{
var currentDesc = gr.getValue('short_description');
gr.setValue('short_description',currentDesc+' ');
gr.update();
gr.setForceUpdate('true');
}
Hope this helps!!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz