- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 07:19 AM
I am looking for a solution to a complex problem and hoping someone can help.
We have a catalog item that allows an end user to request access to multiple groups for multiple users (both variables are list collectors). We currently have this functionality in a custom app and we are trying to get everything convered into the Service Catalog/Service Portal.
To replicate the behavior of the custom app, we need to have on RITM for each user for each group (so that there is an approval process for every user/group combination). The approvers are dependent upon the group so there are different approvers for each group and we need to allow approvers to approve Person A but reject Person B, etc.
For example, the end user can request to have three users added to two groups. We would want to have 6 RITM's created with approvals, but we need to get all of the variables from the catalog item to be available on the RITM's so the approvers have access to them.
Does anyone have a solution for this?
Thanks,
Rhonda
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 12:05 PM
My developer instance is currently under maintenance and I cannot prove what I have. I am including some code I used from another project which will generate multiple requests based off of a CI list variable. You can modify your code so that it will use the proper variables for your project:
generateHwRefreshItem: function(itmObj) {
var array1 =[];
array1 = itmObj.variables.hw_refresh_ci_selection.toString();
var array2 = [];
array2 = array1.split(',');
var Length = array2.length;
for(var i=0; i<Length; i++) {
// add item to existing request
var reqHelper = new global.GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(itmObj.request, 'be474f023772b240ee341aa543990e69', 1); // 1 is the qty
reqHelper.rebalanceRequest(itmObj.request);
// update/add values to variables on item
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', itmObj.request);
grReqItem.addQuery('cat_item','be474f023772b240ee341aa543990e69');
grReqItem.addNullQuery('configuration_item');
grReqItem.query();
if(grReqItem.next()) {
grReqItem.variables.hw_refresh_requested_for = itmObj.variables.hw_refresh_requested_for;
grReqItem.variables.hw_refresh_cost_center = itmObj.variables.hw_refresh_cost_center;
grReqItem.variables.hw_refresh_hw_model = itmObj.variables.hw_refresh_hw_model;
grReqItem.variables.hw_refresh_ci_selection = itmObj.variables.hw_refresh_ci_selection;
grReqItem.variables.hw_refresh_short_description = itmObj.variables.hw_refresh_short_description;
grReqItem.parent = itmObj.sys_id;
grReqItem.configuration_item = array2[i];
grReqItem.update();
}
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 05:51 AM
Thank you so much! That is pretty much what I have and it's almost working. In my scenario, I am populating two variables on the new RITM with values from an array (similar to your grReqItem.configuration_item = array2[i]. They are both reference variables, one is a user, the other is a group. I need to be able to leverage the value of the group variable in the second workflow in order to create a group approval activity. I can't find a way to get the value of the variable.
Any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 06:40 AM
add .value at the end
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2018 04:07 PM
Where does this code go? Should this be a runscript at the beginning of the subflow to create the RITMs and populate them with the variables? Sorry for all of the questions, I am just a little bit confused and this solution seems great so I want to understand (:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 06:46 AM
That didn't work either - I tried:
current.request.variables.ref_user.value
current.variables.ref_user.value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 06:54 AM
Variables are typically found on the Requested Item record. If you have a record that was spawned from the original, can you verify that the variables are there and are filled in? If they are, then you just need to change the approval to use advanced scripting. What I envision is something that points to your variable. For this example I am using a variable called a_group:
answer = current.variables.a_group.toString();
The reason why you need to use the toString() method is that the system expects an array of addresses to use as recipients.