Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to create multiple RITM's in single request

phani Deepthi
Tera Contributor

Hi All,

 

We are working on creating a new server through a service catalog. So there is a variable called "No.of servers" with values till 5. If a requestor selects more than 1 need to create respective RITM's n same request. Ex: If a user selects 2 servers need to create 2 RITM, if 3 then 3 RITM's. Please help me how to achieve this.

 

Thanks

1 ACCEPTED SOLUTION

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @phani Deepthi ,

You can try below BR on RITM table.

replace with your variable name.

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
	var serverValue=current.variables.no_of_servers;
    for (var i = 1; i < serverValue; i++) {
        var gr = new GlideRecord('sc_req_item');
        gr.initialize();
        gr.cat_item = current.cat_item;
        gr.request = current.request;
        gr.insert();
    }


})(current, previous);

GunjanKiratkar_0-1669044141076.png

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

2 REPLIES 2

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @phani Deepthi ,

You can try below BR on RITM table.

replace with your variable name.

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
	var serverValue=current.variables.no_of_servers;
    for (var i = 1; i < serverValue; i++) {
        var gr = new GlideRecord('sc_req_item');
        gr.initialize();
        gr.cat_item = current.cat_item;
        gr.request = current.request;
        gr.insert();
    }


})(current, previous);

GunjanKiratkar_0-1669044141076.png

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

tmalo
Tera Contributor

You can uncheck the "Hide the 'Add to Cart button'" under Portal Settings of the Catalog itemSNowCommunity.jpg.