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

I tried that but it returned undefined.

How did you accomplish this step - how did you get a RITM created for each combination of user/group and get it to have variables? I am able to create the RITMs but they have no variables

wiltonr
Giga Contributor

The child workflow has a 1 second timer after the start activity; the variables are there but it just didn't have enough time to populate them onto the other RITM's.

 

Hmmm I was able to get all the RITMs created on the one original workflow but maybe that is why they dont have the variables..

So you have the original catalog item with the list collectors and that goes into the original workflow which then goes into a subflow. The subflow creates the RITMs then has a timer then the subflow ends and the RITMs return to the original workflow with the variables?

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