Business Rule condition getDisplayValue('document_id')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 08:23 AM
On this table:
I have this Advanced Condition
Question... is the "document_id" field on the sysapproval_approver table a calculated field for getDisplayValue()??
The reason I'm asking is because when all is said and done, I need this business rule condition to be:
Now, in Script Include code, this queries just fine and pulls back perfectly... but when I try the code in this business rule as a condition, it always comes up blank.
Why does getDisplayValue('approver') work in the condition, but not getDisplayValue('document_id') ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 10:12 AM
David,
The sysapproval field would get you what you need except that it is only for task records. If you are trying to get values from a non task record you will need to perform a GlideRecord query to get the data. getDisplayValue() will not work because it's not a reference field. .The other getDisplayValue() method mentioned by AKb Zic will not work in this case because it is client side code not server side code. Here is what you will need to do:
var gr = new GlideRecord(current.source_table);
gr.get(current.document_id);
gs.print(gr.<desired_field_name>);
Hope this helps.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 08:29 AM
David,
I think the way you are using the "getDisplayValue()" is wrong. It should be "current.document_id.getDisplayValue()".
You can also retrieve the sys_id like following "current.getValue("document_id")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 08:36 AM
I forgot in my previous post to mention mu sources. You can get help from this following wiki article : GlideElement - ServiceNow Wiki
@ Timothy : the getDisplayValue() function has nothing to do with a reference field. It only retrieves the "formatted display value of the field"
In order to get the value of a reference field, either you use getReference or you GlideAjax
Here a thread about getReference (you should avoid using it as much as possible because it takes lot of ressources) : GlideForm (g form) - ServiceNow Wiki
Here an article about the GlideAjax : http://wiki.servicenow.com/index.php?title=GlideAjax

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 08:36 AM
No, getDisplayValue() can be used either way.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 08:43 AM
Hi David,
Document ID fields are not the same as Reference fields, so the display value concept is a little different for them. They work in conjunction with another field storing the table name associated with the record.
I think AKb's suggestion is the way to go...
There is more than one flavor of "getDisplayValue()" out there:
- The one available from a GlideRecord (i.e., current.getDisplayValue('document_id')) looks like it is going to return you the sys_id stored in the document_id field.
GlideRecord - ServiceNow Wiki - The one available from a GlideElement (i.e., current.document_id.getDisplayValue()) seems to recognize that document_id is a different type of field and works to get you the proper display value.
GlideElement - ServiceNow Wiki
I would give the second method a try and see how that works for you.
Thanks,
-Brian