order a catalog item
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:37 AM
How to order a catalog item from a background script.
please provide me the code.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:46 AM
Hi @showsid02
Please follow the answer provided by @Matthew Glenn
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:51 PM - edited 10-11-2023 11:00 PM
Hey @showsid02,
Please find below script for your background script,
Do the needful changes as you query.
// Replace these variables with your specific values
var catalogItemSysID = 'your_catalog_item_sys_id';
var requestedFor = 'user_sys_id'; // The user for whom the item is being requested
// Create a request item (RITM)
var ritm = new GlideRecord('sc_req_item');
ritm.initialize();
ritm.setValue('cat_item', catalogItemSysID);
ritm.setValue('requested_for', requestedFor);
ritm.insert();
// Request fulfillment
var request = new GlideappCatalogRequest();
request.orderGuide = 'your_order_guide_sys_id';
request.items = ritm;
var requestId = request.placeOrder();
Regards,
Kamlesh