- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 11:42 AM - edited 05-31-2023 11:43 AM
Hello All,
I have an requirement to create/order Multiple Items as part of our intergation and this is going to be an Inbound Integration , we have 5 items
order laptop
Access to VPN
order Mobile
Order ID
Order keyboard - in this Item I have to set predefined variable values
1. Automatic key board - choice to Yes
we cannot do this as order guide , we need to create as Individual request
So now I need to create 5 Items via Rest API can you please suggest some solution and Sample script ,
@Ankur Bawiskar @Voona Rohila @jaheerhattiwale
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 08:59 PM
I believe you want all 4/ 5 RITMs in same REQ
I created blog for this couple of years ago. have a look
If it helps please mark the blog as helpful
Multiple RITMs in same Request Using CartAPI
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
05-31-2023 10:53 PM
@Michael51 Create a scripted rest api to add the custom code to it and trigger the api from outside the servicenow as you wish.
Send the Request body to the api like below
[
{
"catalog_item_sys_id": "<order laptop CAT ITEM SYS ID HERE>"
},
{
"catalog_item_sys_id": "<Access to VPN CAT ITEM SYS ID HERE>"
},
{
"catalog_item_sys_id": "<order Mobile CAT ITEM SYS ID HERE>"
},
{
"catalog_item_sys_id": "<Order ID CAT ITEM SYS ID HERE>"
},
{
"catalog_item_sys_id": "<Order keyboard CAT ITEM SYS ID HERE>",
"<Automatic key board VARIABLE NAME HERE>": "Yes"
}
]
Steps:
1. Go to "Scripted rest api" module
2. Create new scripted rest api
3. Scroll down to see the related list
4. create a new scripted rest resource
5. Add below code to scripted rest resource
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var requestBody = request.body.data;
for (var i = 0; i < requestBody.length; i++) {
var cart = new Cart();
var item = cart.addItem(requestBody[i].catalog_item_sys_id);
var keys = Object.keys(requestBody[i]);
for (var j = 0; j < keys.length; j++) {
if (keys[j] != "catalog_item_sys_id") {
cart.setVariable(item, keys[j], requestBody[i][keys[j]]);
}
}
var placeOrder = cart.placeOrder();
}
})(request, response);
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 08:59 PM
I believe you want all 4/ 5 RITMs in same REQ
I created blog for this couple of years ago. have a look
If it helps please mark the blog as helpful
Multiple RITMs in same Request Using CartAPI
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
05-31-2023 09:34 PM
Thanks for your reply Ankur , It should be individual Request and RITM , I mean each item each request and RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 10:33 PM
then you can use cart API and submit the individual REQ and RITM
what did you start with?
check these links
Submit a catalog item through Email inbound action
you can also use flow designer for this
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 10:36 PM
Thanks Ankur , Can I have sample fot flow designer?