Looking for solution for multiple RITMs from same Catalog Item

wiltonr
Giga Contributor

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

 

 

 

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

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();
            }
        }
    },

View solution in original post

22 REPLIES 22

ccajohnson
Kilo Sage

Rather than outlining the entire solution, I will give you a high-level way of achieving this.

You have your two list collector variables from your original request. In that request's workflow you will need to get the user and group id combinations from those two list collectors. Using your example, you have two people to be added to two groups:
- User A
- User B
- Group 1
- Group 2
- Group 3
Combination results:
- User A,Group 1
- User B,Group 1
- User A,Group 2
- User B,Group 2
- User A,Group 3
- User B,Group 3
Since you now have the six combinations, you will need to generate the Request Items for each.
I would have a similar Catalog Item as your original request, but have it point to a second workflow that will actually execute the request for each of the combinations.
I would have two reference variables, one for the user and one for the group (in lieu of the original user and group list variables). Those you would use to populate the combination results to. All other variables you can get from the original request (using variable sets comes in handy here). Also, when generating the requested items, you will populate the parent field of the new item with the sys_id of the original. That way, it can be associated accordingly.

Thanks for the reply - that mostly makes sense.  You would have the original catalog item and then another similar catalog item with a different workflow.  That workflow is called from the first one for each user/group combination, so called 6 times?

While it makes sense, I'm not really sure how to accomplish it.  

Could you get me started?

I mostly have this working.  I am able to do what you suggested, and get a RITM created for each combination of user/group calling the second workflow that has a single reference variable for the group and user.  

My newest challenge is how do I leverage those variables in the second workflow?  In each of the RITM's, I need to generate group approvals based upon the group that is populated into the variable field, but when I log current.variables.ref_user in the second workflow, I don't get a value.  

Any ideas?

try current.request.variables.ref_user


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!