- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 10:29 PM
I am using Cart api to set Requested_for field for different users,but still the requested for is showing my name only
is there any way to set the requested_for by using Cart API
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 10:50 PM
Unfortunately you cannot set any fields of REQ or RITM using Cart API
the only way is to get the REQ sys_id and then set the value
sample script 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('4054428fdb151f0097679ec6db9619c0', 1);
//fill in the variables on the request item form
cart.setVariable(item,"u_requested_for", "e80edd6edbec6bc097275e25ca9619a4");
cart.setVariable(item,"contact_number", "0");
cart.setVariable(item,"assignment_group", "87ec1c342b2e71406c487fb5a8da1524");
cart.setVariable(item,"application_service", "cdedfbcedb0f9744c291c170ba9619a7");
var rc = cart.placeOrder();
var reqRecord = new GlideRecord('sc_request');
reqRecord.get(rc.sys_id);
reqRecord.requested_for = 'user sys_id you want here';
reqRecord.update();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2023 10:19 PM
Can you post a new question for this as this is an older thread? please tag me there
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2023 10:46 PM
Posted a new question. If you could please help me in figuring it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 10:52 PM
You can, using cartJS:
var cart = new sn_sc.CartJS();
cart.setRequestedFor("039c516237b1300054b6a3549dbe5dfc")//sys_id of the requested for you want
var item =
{
'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',//sys_id of the item
'sysparm_quantity': '1',
'variables':{
'contact_number': '0',
//add more variables here
}};
var cartDetails = cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();
Also refer to:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2020 07:41 PM
I have around 700 records with different values for RITM variables all are there in excel sheet, how can i proceed with above script ?
should I manually update the variable values one by one in the above script and run that script or is there any other way to proceed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2020 09:31 PM
if you have the variables in the excel file then I would suggest parse the excel row by row and then use the above script to create those many RITMs and REQs.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader