- 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 06:59 AM
Yes, the child RITM has the variables filled in as expected. I have three variables on the child RITM - two of them are populated from the array in the parent RITM workflow - a user and a group.
But in the child wofklow I am having absolutely no luck getting the value of the group variable. (And fyi, the answer for the approval isn't going to be that group. I need to use that group, and then go query for the group's parent - that's who gets the approval. But the bottom line is, on the child worfklow, I cannot access the group variable value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 07:08 AM
I wonder if the value isn't there when the workflow runs but that doesn't make sense. I am querying the sc_item_option table, and I can find the record and return values for both the Question and the Cart Item, so the record is there, but Value returns nothing. If I later run a background script doing the exact same thing it returns a value.
From what I read, I don't think I can pass values from the parent workflow to the child workflow when it's on the Requested Item table. I don't know how else to get this approval created without being able to access the group value when I get to the child workflow. 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 07:18 AM
I have seen things whereby the workflow needs to wait one second for the record to be completely updated. My guess is that your approval is happening right away on your child workflow. See if you can add a Timer workflow activity and set it to be only 1 second. Really not sure why you are looking on the sc_item_option table since that is where you define the variable attributes and not the value of the variable for the record in question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 07:16 AM
Try running something similar in scripts background:
var current = new GlideRecord('sc_req_item');
current.get('8a5055c9c61122780043563ef53438e3'); //change the sys_id to the record you want to check.
gs.print(current.variables.a_group.parent.getDisplayValue());
That should prove that you have a variable value for the record in question. If that works, then add that to your child workflow which should contain the approval using the syntax I used earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 07:28 AM
So all I needed was a timer - with a timer in the child worfklow I can access the variable by current.variables.ref_user.
Been banging my head on that one. 😞
Thanks so much!