- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 06:47 AM
Hello everyone, hope all is well,
I need to know how i can get the RITM number from a catalog item created in my workflow. I have a catalog item workflow, and towards the end of that workflow i am launching another catalog item. I need the RITM number from the newly launched catalog item to be in the work notes of the original catalog item, i believe this is possible i just dont know the correct syntax to use. Can anyone point me in the right direction?
Run script for logging to work notes:
current.work_notes = 'Work at Home Hardware Request has been created';
//var ritm = new GlideRecord('sc_req_item');
//ritm.addQuery('request');
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 09:03 AM
So your scripts should be:
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('e66cb93a4f236f00259db3318110c76e', 1);
//fill in the variables on the request item form
cart.setVariable(item, 'requested_for', current.request.requested_for);
cart.setVariable(item, 'opened_by', current.request.opened_by);
cart.setVariable(item, 'work_at_home_coordinator', current.request.opened_by);
cart.setVariable(item, 'requested_for_supervisor', current.request.requested_for.manager);
var rc = cart.placeOrder();
workflow.scratchpad.request_number = rc.sys_id; //so it can be referenced later
and
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', workflow.scratchpad.request_number);
ritm.query();
if (ritm.next()) {
// access to ritm here
current.work_notes = 'Work at Home Hardware Request has been created:' + ritm.number;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 07:31 AM
If you add this in your generation 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('e66cb93a4f236f00259db3318110c76e', 1);
//fill in the variables on the request item form
cart.setVariable(item, 'requested_for', current.request.requested_for);
cart.setVariable(item, 'opened_by', current.request.opened_by);
cart.setVariable(item, 'work_at_home_coordinator', current.request.opened_by);
cart.setVariable(item, 'requested_for_supervisor', current.request.requested_for.manager);
var rc = cart.placeOrder();
workflow.scratchpad.request_number = rc; //so it can be referenced later
You should be able to reference it in a later activity by doing:
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', workflow.scratchpad.request_number);
ritm.query();
if(ritm.next()) {
// access to ritm here
}
Please mark my answer as helpful/correct if it resolved your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 08:18 AM
For some reason, its giving me the REQ# instead of the RITM#

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 08:19 AM
What is? RC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 08:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 08:27 AM
Can you post the code that is writing that note? You should be using ritm.number to get the ritm number.