- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 06:45 AM
Hi Everyone,
I have a requirement to create an RITM by submitting the catalog item from UI Action script.
Instance Version : Tokyo
Note : UI Action is on a table which is Custom scoped table and the Catalog item which needs to be created RITM is Global one.
Can anyone help me with the script here?
@Ankur Bawiskar Any idea on this Ankur?
Thanks in Advance,
Balaraju K B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 10:53 PM
try this and it works in global + scope
try{
var cart = new sn_sc.CartJS();
var item =
{
'sysparm_id': '0336c34407d0d010540bf2508c1ed096',
'sysparm_quantity': '1',
'variables':{
'user': '7282abf03710200044e0bfc8bcbe5d03',
'asset': '00a96c0d3790200044e0bfc8bcbe5dc3',
'multiple_choice': 'Phoenix',
}};
var cartDetails = cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();
gs.info('Order details' + JSON.stringify(checkoutInfo));
}
catch(ex){
gs.info('Exception'+ex);
}
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
03-29-2023 10:20 PM
@Ankur Bawiskar Tried in PDI from Global scope it is working but if i Create UI Action in Scoped Application then its giving error as shown below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 10:53 PM
try this and it works in global + scope
try{
var cart = new sn_sc.CartJS();
var item =
{
'sysparm_id': '0336c34407d0d010540bf2508c1ed096',
'sysparm_quantity': '1',
'variables':{
'user': '7282abf03710200044e0bfc8bcbe5d03',
'asset': '00a96c0d3790200044e0bfc8bcbe5dc3',
'multiple_choice': 'Phoenix',
}};
var cartDetails = cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();
gs.info('Order details' + JSON.stringify(checkoutInfo));
}
catch(ex){
gs.info('Exception'+ex);
}
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
03-29-2023 11:29 PM
@Ankur Bawiskar How can i set the variables dynamically using current object?
and action.setRedirectURL is not working RITM is getting created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 01:28 AM
are you able to create the RITM and REQ using hard-coded variable values?
If yes then just use current.fieldName to get the value and set in variable
Ensure field type and variable type are same.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 03:34 AM - edited 03-30-2023 03:38 AM
@Ankur Bawiskar Yes creating the RITM but On using current.<field name> to set the variable it is setting only {} braces as highlighted below :
Note : Field type and Variable type is same (multi line text)