Create multiple RITM based on data in MRVS using Flow Designer

iDNS
Tera Expert

Hi, has anyone worked on creating multiple RITMs based on data from MRVS using Flow Designer & not via WorkflowI have tried to create record & also Submit Catalog which haven't been quite fruitful as expected. The ask is as below. Thanks in advance 

  • Check the # of rows in the MRVS
    • If 1 record
      • Do nothing & process with the Flow
    • If more than 1 record
      • Create a RITM for each of the rows in MRVS  under the same REQ
      • Close the first RITM
12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@iDNS 

you can determine how many rows are there in MRVS using for each and then check the count

Then use IF logic to check the number of rows

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

 

Thanks for responding, I have a Flow Variable named mrvsCount post I get Catalog Variables. This gives me the count. I am able to proceed if the count is 1. If the count is >1, I am struggling to decide the best way to create multiple RITMs related to the same REQ with parsing the variables into the new RITMs. 

 

Any suggestions would be very helpful. Thanks

var array = fd_data._1__get_catalog_variables.network_drive_access;
var count = array.length;
return count;

 

 

iDNS_1-1735827583477.png

 

 

Zuber1
Tera Contributor

@iDNS 

I did something like this and it sounds similar to what you're seeking to do:

Create a flow action

Provide MRVS as input, using type of JSON object - array in this example

 

Use script action, create script input, using MRVS from action input - array in this example

 

 

(function execute(inputs, outputs) {

    for (i = 0; i < inputs.array.length; i++) {

        var cart = new sn_sc.CartJS();

        var jsonObj = inputs.array[i];

        var parser = JSON.parse(JSON.stringify(jsonObj));

        var item = {

            'sysparm_id': 'insertYourSysID',

            'sysparm_quantity': '1',

            'variables': {

                'variable1': (parser.variable1),

                'variable2': (parser.variable2)

            }

        };

        var cartDetails = cart.addToCart(item);

    }

    var checkoutInfo = cart.checkoutCart();

    outputs.request_number = checkoutInfo.request_number;

})(inputs, outputs);


here is the documentation for cartJS, it was very helpful for our use case:
CartJS