Get all the sys_ids of all P1(priority-1) incidents in incident table and populate all thoose sys ids into any one of P3(priority-3) incident work notes(filed).

Ravi Shankar Te
Tera Contributor

Hi  everyone,

can anyone help me with this question

1 ACCEPTED SOLUTION

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi Ravi,

            Refer below script (tested in background script, working as per your requirement)

var priority1Arr =[]; 
var updatedP3;
var inc = new GlideRecord('incident');
    inc.addActiveQuery();
    inc.addQuery('priority',1);
    inc.query();

// pulling all p1 incident sys_id 
while(inc.next()){
		priority1Arr.push(inc.getUniqueValue());
	}

// setting those id in any P3 incident work notes
var incp3 = new GlideRecord('incident');
    incp3.addActiveQuery();
    incp3.addQuery('priority',3);
    incp3.query();
if(incp3.next()){
                updatedP3 = incp3.number;
		incp3.work_notes += priority1Arr;
                incp3.update();
	}

gs.print("Done Updated in " + updatedP3); // getting record where all sys_id are setted

 

Kindly mark correct and helpful if applicable

View solution in original post

9 REPLIES 9

It is working chetan, thankyou very much.

Ravi Shankar Te
Tera Contributor

I want this for one time only. And i tried background but it is not working .

Dharshan N B
Tera Expert

Hi Team,
can i know the procedure how to do this using glide ajax and script includes

 

i am kind of new to Servicenow

Hello @Dharshan N B ,

                                          Please find this article to understand Script include How to call script include from client script | #servicenow #GlideAjax 

 

Kindly mark helpful if applicable