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

Anand Shukla
Mega Guru

Hi Ravi,

If its a one time task you can use the background script and save all the P1 incident sys_id on any P3 incident of your choice.

OR

If its based on scheduled like every week then you can use a scheduled job for this.

 

I hope it helps you.

 

Thanks 

Anand

 i want this for one time only and i used background script but it is not working.

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

Hi chetan i will refer and update you.

 

Thanks.