doing script for creating catlaog request by email inbound action script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2023 01:47 AM
I have a requirement for scripting by using email inbound action I have to raise a catalog request through an emai.I'm writing this script but this is not working.Are there any complications in this code.can anyone let me know.Even though it is reflecting in system logs a created.Yet it creating under Incident table, even though I Gave table as sc_request in inbound email action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2023 02:11 AM
Hi,
You need to Cart API as you are implementing this in inbound email (server-side script). You can use Cart JS API for any client-side
Please refer the code below:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('sys_id', 1);
//Fill the variables
cart.setVariable(item,"u_requested_for", "req_sys_id");
var rc = cart.placeOrder();
Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2023 02:20 AM
Hi @sainath reddy ,
Could see cat_item value as some string it should be sys_id of the catalog item and don't see requested_for value defined.
try executing this logic in the background script as below (in dev) using static values and check if any issues.
Output:
we have another way of submitting catalog item using cartAPI
Option 2:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('sys_id of the catalog item');
cart.setVariable(item,'variable backendname',value);// example cart.setVariable(item,'requested_for','sys_id of the user');
cart.setVariable(item,'variable backend name',value); // example cart.setVariable(item,'notes','1234');
var rc = cart.placeOrder(); //rc is the sys_id of the request
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 02:43 AM
it is creating under incident table.even if the changes had made

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 03:04 AM
Hi @sainath reddy ,
What do you mean its creating under incident table?? is it creating a incident record?
did you check in the request table for any new requests
we would like to know more about inbound action condition (may be another inbound is triggering )
check inbound logs , it gives which inbound actions are executed/skipped
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025