adding an IF statement that handles the return value if it's a sys_id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 05:24 PM
hi all,
I've got a GlideRecord that is retrieving the variables and values from a record. However one type of variable on the record is a reference to a table that extends the Data Lookup Matcher Rules table, and for those variables it is returning the sys_id. I need it to return the actual entry for the field. I'm thinking I need an IF statement in my script to check for this particular type of variable, and then to return the display value, not the sys_id.
Any help would be great!
The script below is returning the screen shot below that. Those sys_id values are the variable that are references to a table extending the Data Lookup Matcher Rules table.
var qa = new GlideRecord('question_answer');
qa.addQuery('table_sys_id', current.sys_id);
qa.orderBy('order');
qa.query();
var a ='';
var q = '';
var ind ='';
while(qa.next())
{
q = qa.question.getDisplayValue()+'';
if (qa.question.reference!='')
{
var qq = new GlideRecord(qa.question.reference);
qq.get(qa.value);
a = qq.getDisplayValue();
}
else
{
a = qa.value;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 07:54 AM
Hi Anudeep,
the answer for these variables is actually being defined in this line.
a = qa.value;
I know this because if I just put
a = "hello";
in my script:
var a ='';
var q = '';
var ind ='';
while(qa.next())
{
q = qa.question.getDisplayValue()+'';
if (qa.question.reference!='')
{
var qq = new GlideRecord(qa.question.reference.getDisplayValue());
qq.get(qa.value);
a = qq.getDisplayValue();
}
else
{
a = 'hello';
then I get this result, and see how the variables in question return "hello". So these are not being defined in the "if" part, they are being defined in the "else" part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 12:15 PM
so I just realized that it is not a problem because the table type is Data Lookup Matching Rules, it is because of the mapping elements involved. I changed the reference fields to straight master data tables and it worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 06:45 PM
Glad it worked
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin