How can I fetch first 100 records

shidhartha
Tera Contributor

How can I fetch first 100 records from incident tables and update to priority 1 

4 REPLIES 4

Community Alums
Not applicable

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

Community Alums
Not applicable

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

Jaspal Singh
Mega Patron
Mega Patron

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();
}

Hitoshi Ozawa
Giga Sage
Giga Sage

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();
}