- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 07:38 AM
Variables is empty for GlideRecord query record, even though it has variables.
var req = new GlideRecord('sc_req_item');
req.addQuery('sys_id','=','XXXXXXXXXXXXX');
req.query();
while (req.next()) {
// req.variables is empty
}
How to get the variables value ?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 06:52 AM
Figured out that the value of variables is empty on client script but works fine on business script.
Prateek's solution is partially working on client script but need to query two more additional tables sc_item_option and item_option_new to get variable value and name.
Thanks for all your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 08:19 AM
Here you go:>
var req = new GlideRecord('sc_item_option_mtom');
req.addQuery('request_item','9b00524a13848b4443143482e144b0bd'); //replace with sys_id
req.query();
while (req.next()) {
gs.print("Question: "+req.sc_item_option.item_option_new.getDisplayValue() +'\n'+ "Value Assosciated: "+ req.sc_item_option.value.getDisplayValue());
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 11:44 AM
Thanks Prateek.
I was able to query sc_item_option_mtom with sys_id. But req.sc_item_option is a string (like sys_id).
So req.sc_item_option.item_option_new is undefined.
Do you know how do I get variable name and value from this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 06:52 AM
Figured out that the value of variables is empty on client script but works fine on business script.
Prateek's solution is partially working on client script but need to query two more additional tables sc_item_option and item_option_new to get variable value and name.
Thanks for all your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 07:09 AM
Cool, Glad that you got it working .
Share your script here so that others in similar situation can make use of it.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks