How can I fetch first 100 records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:40 AM
How can I fetch first 100 records from incident tables and update to priority 1
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:44 AM
Hi,
This article should help you :https://community.servicenow.com/community?id=community_blog&sys_id=60ccee25dbd0dbc01dcaf3231f961946
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 08:47 PM
Hi,
Any update to this ?Any follow-up required? if not
Kindly mark the answer as Correct & Helpful both such that others can get help.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:51 AM
Someghing as below.
But is it not in your case that priority is dependant on impact & urgency?
var inci=new GlideRecord('incident');
inci.orderBy('sys_created_on');
inci.setLimit(1);
inci.query();
while(inci.next())
{
inci.priority='1';
inci.setWorkflow(false);
inci.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:51 PM
Hi Shidhartha
Jaspal's reply is almost correct but it would only update the oldest record. Also, field "priority" is of type "Integer".
To update the oldest 100 incident, the script is as follows.
var inci = new GlideRecord('incident');
inci.orderBy('sys_created_on');
inci.setLimit(100);
inci.query();
while (inci.next()) {
inci.priority = 1;
inci.setWorkflow(false);
inci.update();
}