How to query approval status from multi row variable set

vahini
Giga Guru

Hello all, 

Please read my requirement below and advise on how to get it done.

Thanks In advance for reading my post till the end, appreciate your time.

 

I created a list collector referenced to u_cmdb_ci_ad_group table and a multi row variable set (active_directory_record_list)  which is hidden on form and visible only on RITM after submission.

 

List collector

 

 

Multi row variable set looks like below 

 

 

 

if any of AD Group has no secondary approver then it's automatically marked as Approved by some script ,and if there is a secondary approver then it's sent for approval to that person and that person might approve or reject.

 

once approval is done, in the next step i am sending a payload to OIM tool and in it sending approved groups.

 

currently i am sending all approved groups in payload , but customer wants to see only approved AD groups and not rejected one.

 

querying selected AD groups against cmdb_ci_ad_group table and finding display values.

vahini_3-1737470859638.png

 

adding all those groups in the payload.

vahini_4-1737470897413.png

 

in below screen shot highlighted group was rejected as shown in RITM (2nd screen shot above ), this should not go in the payload.

vahini_5-1737471114911.png

 

Please advise on how to get only approved groups and send it in payload. 

 

Thank you so much for your time.

 

 

1 ACCEPTED SOLUTION

Hi Ankur, 

 

I used the code you posted and modified it to below code, but it's throwing one error, not sure whats wrong in code, all variables are correct names.

 

var parseData = JSON.parse(fd_data._1__get_catalog_variables.active_directory_record_list.toString());
var approvedGroup = [];
for(var i=0;i<parseData.length;i++){
// use correct variable name and value to compare
if(parseData.approval_status.toString() == 'approved')
{
approvedGroup.push(parseData.u_select_group.toString()); // use correct group name variable within MRVS
}
}
return approvedGroup.toString();

 

vahini_0-1737483988457.png

 

View solution in original post

6 REPLIES 6

@vahini 

I believe I answered your question as well based on what information you had shared.

I didn't know what that script include does as you didn't share code with us.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

vahini
Giga Guru
//This reply is to tell you what these two variable are
 
//active_directory_record_list  is the MRVS which hasa 3 columns in which Approval status is one column
//u_cmdb_ci_ad_group  is the table which stroes the AD groups selected

 

var approvedADGgroups = [];

 

var mrvsAapproval = JSON.parse(fd_data.trigger.request_item.variables.active_directory_record_list.toString());
for (var i = 0; i < mrvsAapproval.length; i++) {
    if (mrvsAapproval[i].approval_status == 'approved') {
        approvedADGgroups.push(mrvsAapproval[i].u_select_group)
    }
}

 

var t = 'u_cmdb_ci_ad_group';
var l = approvedADGgroups;
var dv = new getLCDisplayValues().getValues(t, l);
return dv.trim();