- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 12:32 PM
Curious if there is a way to achieve this.
I have a script which is manually creating a REQ and RITM records, as well as assigning the cat_item to the RITM record. The actual flow itself appears to work successfully and a SCTASK is generated as expected.
The issue I'm seeing (albeit minor) is that the variables are not displaying on the RITM or SCTASK form level.
Is there an optimal way to ensure the variables are also reflected on the form?
Script:
// Create Request
var reqGR = new GlideRecord('sc_request');
reqGR.initialize();
reqGR.requested_for = incCaller;
reqGR.short_description = incShortDesc;
reqGR.description = incDesc;
reqGR.insert();
// Create RITM
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.initialize();
ritmGR.request = reqGR.sys_id;
ritmGR.requested_for = incCaller;
ritmGR.short_description = incShortDesc;
ritmGR.description = incDesc;
ritmGR.cat_item = 'd4ef8fc11b21c8106b1843f9cd4bcb93'; // Catalog item sys_id
ritmGR.insert();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 08:18 PM
you should use Cart API or CartJS to submit request and you can populate variables as well
With this you will start seeing the Variable editor on RITM form and also your flow/workflow will trigger
Something like this
try{
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('0336c34407d0d010540bf2508c1ed096', 1);
//fill in the variables on the request item form
cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
cart.setVariable(item, "multiple_choice", "Phoenix");
var rc = cart.placeOrder();
gs.info(rc.number);
}
catch(ex){
gs.info(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
04-24-2025 12:42 PM - edited 04-24-2025 12:43 PM
Variables are added to the Requested Item by the ordering process. So the easiest and quickest way to go about what you would like is to just use the Cart API to order the cat item using your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 08:18 PM
you should use Cart API or CartJS to submit request and you can populate variables as well
With this you will start seeing the Variable editor on RITM form and also your flow/workflow will trigger
Something like this
try{
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('0336c34407d0d010540bf2508c1ed096', 1);
//fill in the variables on the request item form
cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
cart.setVariable(item, "multiple_choice", "Phoenix");
var rc = cart.placeOrder();
gs.info(rc.number);
}
catch(ex){
gs.info(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
04-27-2025 07:45 PM
Hope you are doing good.
Did my reply answer your question?
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
04-29-2025 08:09 AM
Sorry for the delay getting back to you. This was a perfect solution and worked without issue! Thanks so much!