- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 08:28 PM
Hi Developers,
I want to create a RITM when record producer submitted up and few values from record producer should be populated on catalog item.
RITM have field
Name
Description
Short description
Submit
from backend Catalog item "Submit IT request" have fields Requested For, Description and Short description should be autopulated from Name, Description and Short description respectively. Catalog item is not visible to end user .
Client script on Record producer-
function onSubmit() {
//Type appropriate comment here, and begin script below
var userID = g_form.getValue('requested_for');
var shortDesc = g_form.getValue('short_description');
var Desc = g_form.getValue('description');
var ga = new GlideAjax('pkkRequest');
ga.addParam('sysparm_name', 'createRequest');
ga.addParam('sysparm_userID', "userID");
ga.addParam('sysparm_shortDesc', "shortDesc");
ga.addParam('sysparm_Desc', "Desc");
ga.getXML(HelloWorldParse);
}
function HelloWorldParse(response) {
}
SI : pkkRequest
createRequest: function() {
var userID = this.getParameter('sysparm_userID');
var shortDesc = this.getParameter('sysparm_shortDesc');
var Desc = this.getParameter('sysparm_Desc');
var cart = new sn_sc.CartJS();
var request1 = {
'sysparm_id': 'ec10f4fd47266110b81cd855d36d4308', // sys_id of catalog item
'sysparm_quantity': '1',
'variables': {
'requested_for': userID, //'8efae6cbdb038b00d6563cae7c961
'short_description': shortDesc,
'description': Desc
}
};
var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(request);
var requestDetails = cart.submitOrder(request);
},
RITM is being created but dynamically values are not getting populated on ritm variables
Appreciate in advance
Thanks
Kaushal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 08:58 PM
why to do this in onSubmit and use GlideAjax?
You can simply do this in Record producer script and replace the values dynamically
Use this script in Record producer script
var cart = new sn_sc.CartJS();
var request1 = {
'sysparm_id': 'ec10f4fd47266110b81cd855d36d4308', // sys_id of catalog item
'sysparm_quantity': '1',
'variables': {
'requested_for': producer.requested_for, //'8efae6cbdb038b00d6563cae7c961
'short_description': producer.short_description,
'description': producer.description
}
};
var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(request);
var requestDetails = cart.submitOrder(request);
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
‎05-03-2023 08:47 PM
Hi @Prashant52 ,
Hope you are doing well.
As you mentioned you have user on-submit client script.
Just to let you know that on-submit client script is not compatible with async ajax. If your requirement is only to run in native UI and not in portal may I suggest you to use getXMLWait.
Just a thought - Why not we update our code in script section of record producer, it will after we submit the record ?
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 08:58 PM
why to do this in onSubmit and use GlideAjax?
You can simply do this in Record producer script and replace the values dynamically
Use this script in Record producer script
var cart = new sn_sc.CartJS();
var request1 = {
'sysparm_id': 'ec10f4fd47266110b81cd855d36d4308', // sys_id of catalog item
'sysparm_quantity': '1',
'variables': {
'requested_for': producer.requested_for, //'8efae6cbdb038b00d6563cae7c961
'short_description': producer.short_description,
'description': producer.description
}
};
var checkoutInfo = cart.checkoutCart();
var cartDetails = cart.orderNow(request);
var requestDetails = cart.submitOrder(request);
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
‎05-11-2023 09:12 PM
Thankyou this is working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2024 05:50 AM
Hello Ankur, could you please provide solution for several different catalog items? Lets say I have 3 catalog items I need to request from an Inbound Email Action for a user. Do you know how to achieve this using CartJS API?
Thanks!