- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 06:54 AM - edited 01-23-2025 09:12 AM
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.
adding all those groups in the payload.
in below screen shot highlighted group was rejected as shown in RITM (2nd screen shot above ), this should not go in the payload.
Please advise on how to get only approved groups and send it in payload.
Thank you so much for your time.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 10:26 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:04 AM
you can get the complete MRVS JSON, iterate and then check the status is approved then only push that value in array
what is the script include and the function?
something like this
var parsedData = JSON.parse(fd_data._1__get_catalog_variables.active_directory_record_list.toString());
var approvedGroup = [];
for(var i=0;i<parsedData.length;i++){
// use correct variable name and value to compare
if(parsedData.approval_status.toString() == 'Approved')
approvedGroup.push(parsedData.group_name.toString()); // use correct group name variable within MRVS
}
return approvedGroup.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 10:26 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:01 PM
did you publish the flow because now in your script there is no script include code but the logs say error in script include
Script looks fine to me
Are you using the correct variable names and value to compare?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 09:14 AM
Below script worked for me
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();