- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 08:29 PM
Hi,
We are using custom checkout widget with CartJS checkoutcart API to create Requested Item and Request. During creation we want to update few fields on Request and Request item table. Do we have any functions in CartJS to update the fields on Request and Request item ?
Regards,
Thenmozhi
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 09:11 PM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
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-02-2020 10:44 PM
Hi,
you can use the object which is returned from the placeOrder() function to set the request values
The API only allows you to set variables, so the standard way to populate fields is to use the request sysid that the cart api gives you then perform query & set Req fields and then the requested items associated with the request and populate field values.
refer below sample script
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();
rc.requested_for = 'sys_id';
//set your fields here for request
rc.update();
var ritm= new GlideRecord('sc_req_item');
ritm.addQuery('request',rc.sys_id);
ritm.query();
while(ritm.next()){
ritm.short_description=email.subject;
ritm.<field name>=<value>;
//set your fields here for RITM
ritm.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-04-2020 08:05 AM
Hi,
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
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-2020 06:12 PM
Hi Ankur,
We have added user defined fields to the request and requested item table. Does the API have an option to set user defined fields(custom fields) for the request and requested item?
Looking forward to your response.
Regards,
Shilpa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 09:13 PM
Hi Shilpa,
No you cannot set custom fields directly using Cart API.
You will have to follow approach mentioned above.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader