How to get all the Catalog Items from all the SCTasks assigned to all my groups using script include

symonflores_23
Tera Guru

I want to get the list of all the ITEMs from all of my SCTasks.

 

1. Get all SCTasks assigned to is (dynamic) one my groups. (assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744)

 

2. Get all Items from all the SCTasks in the query. SCTASK > RITM > RITM.ITEM

 

3. Create an array, push all sysid of the 'ITEM' related to me inside the array, there should be no duplicates.

 

4. Return the array of all 'ITEM'.

 

Huge thanks to anyone who can help!

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hey @symonflores_23,

 

Something like below will help you;

var sctaskGr = new GlideRecord('sc_task');
sctaskGr.addEncodedQuery("assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744");
sctaskGr.query();

var itemArr = [];

while (sctaskGr.next()) {
    itemArr.push(sctaskGr.request_item.cat_item.toString());
}

var arrUtil = new ArrayUtil();

return arrUtil.unique(itemArr);

 

Cheers

 

View solution in original post

1 REPLY 1

James Chun
Kilo Patron

Hey @symonflores_23,

 

Something like below will help you;

var sctaskGr = new GlideRecord('sc_task');
sctaskGr.addEncodedQuery("assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744");
sctaskGr.query();

var itemArr = [];

while (sctaskGr.next()) {
    itemArr.push(sctaskGr.request_item.cat_item.toString());
}

var arrUtil = new ArrayUtil();

return arrUtil.unique(itemArr);

 

Cheers