Flow Designer to Submit Catalog Item Request under the same REQ #
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 12:27 PM
good day all
i created a flow that will trigger automatically every quarter where it will submit three Catalog Item request for each individual item.
What is happening, for each Catalog item submitted its creating three different REQ# for each but i need to have all three items listed under the same REQ#
What i thought to do is to get the Request number of the first Catalog Item that was created and update the other two with that REQ#
that seem to work but now i have two REQ# with no RITM number listed in it
each time this run it will create three REQ#, two that are empty and one with all three items in it
is there a better way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 11:28 PM
I have created blog for something similar.
try to refer that and enhance it by using custom script in flow
Multiple RITMs in same Request Using CartAPI
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 05:17 AM
thank you for the article but where would i put this script in Flow Designer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 05:49 AM
Glad that the article helped.
Please mark it helpful and also bookmark it.
just trigger flow as per your schedule and create custom flow action and use the script.
You already know which catalog items to submit so just use the correct variables and catalog item sysId
Custom Action in ServiceNow Flow Designer
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 06:04 AM
From your code the Action Input would be a variable - String
and the Action output would be outputs.rc = cart.placeOrder()
so the full code for the Custom ACtion would be like:
(function execute(inputs, outputs) {
var catalogItem = 'b70c34e807334c10540bf2508c1ed073'; // catalog item sys_id
var jsonArray = [{"requested_for":"Abel Tuter","requested_by":"Sam Jone","model":"Hyundai","quantity":1,"device_model_name":"Car-Petrol"},{"requested_for":"Fred Luddy","requested_by":"Amy Jone","model":"Honda","quantity":1,"device_model_name":"Car-Diesel"}];
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
for(var i=0;i<jsonArray.length;i++){
var jsonObj = jsonArray[i];
var parser = JSON.parse(JSON.stringify(jsonObj));
var item = cart.addItem(catalogItem,1);
cart.setVariable(item, 'requested_for', parser.requested_for);
cart.setVariable(item,'requested_by',parser.requested_by);
cart.setVariable(item,'model', parser.model);
cart.setVariable(item,'quantity', parser.quantity);
cart.setVariable(item,'device_model_name', parser.device_model_name);
}
outputs.rc = cart.placeOrder();
})(inputs, outputs);