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-27-2017 07:56 PM
Hi Patrick,
I ran your script and looks like its working as expected.
Could you verify the table the variable is referring to has a display value set to the field you are expecting, because if no value is set then sys_id would be used as the table's display value.
Hope this helps Patrick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 08:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 09:02 PM
Hi Patrick,
You dont have to make another query to get the display value.
qa.question.reference.getDisplayValue(); - This should get you the display value.
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 09:13 PM
thanks Antin,
so did I add that in the correct spot? See below, still got the sys_ids for those specific variables...notice that the other ones work fine.
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.getDisplayValue());
qq.get(qa.value);
a = qq.getDisplayValue();
}
else
{
a = qa.value;