
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-17-2020 05:13 AM
I’ve seen this question come up a few times lately, so I thought I’d take a moment to make an article about it. There are certain situations where you need to pull data from RITM variables where the RITM itself is not the current record (such as when running a background script) and the way to accomplish this isn’t overly obvious.
Partially this is because the way RITM variable values are stored is not easy to dissect and actually involves several tables, but also partially because it’s easy to overlook some features that make it easier to accomplish than you might think.
Since you may be looking for an explanation on how variables are actually stored in the tables, I’ll provide a breakdown of the structure. There are 3 main tables involved; sc_req_item, sc_item_option_mtom and sc_item_option.
The actual values are stored in the sc_item_option table, but that able alone isn’t enough. The sc_item_option_mtom table is the key. In order to find the values for a specific RITM, you have to query the sc_item_option_mtom table for the records where the request_item is your RITM. From there you can take the value of the sc_item_option field and query the sc_item_option table to find the record that hold the specific value for that variable on your RITM.
Following this path, you would need to write three nested queries to get to the sc_item_option records that you want. The good news is, there is an incredibly easy short-cut you can use.
Let’s say you have a RITM with a number of RITM0010014 that has 3 variables on it, summary, description and due_date. From any server-side script you can easily get the values of those variables like this:
var values = '';
var ritm = 'RITM0010014';
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', ritm);
gr.query();
while(gr.next()) {
values += 'Summary is: ' + gr.variables.summary + ',';
values += 'Description is: ' + gr.variables.description + ',';
values += 'Due Date is: ' + gr.variables.due_date;
}
gs.info(values);
Easy, right? It’s identical to what you can do when your RITM is the value for current!
If you found this helpful or informative, please be kind and click appropriately!
Maybe bookmark this for later reference 🙂
- 38,240 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is a really very helpful solution! Thanks for sharing!
I'm actually looking for a client script to populate few variable values of a RITM in the catalog request form when a user selects a RITM. Tried several ways, but none of them works. Would you be able to help with this?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I'm working on a changetask which is driven using workflow, the change task is the child of the change request and the change request is the child of the RITM. I want to fetch RITM variables I am using this code
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am getting this error "AttQueueService - processTargetRecord aborted for CTASK0038117. Record is not on a supported table"
when i run my code and change task is child of change request and change request is child of RITM, my aim is to fetch RITM variables and use it as an input to action