getvalue of Short Field Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 08:34 AM
I am trying to get value form "Field Name" on one of the audit tables.
these Field Name fields have a type of short field name.
var rs2 = new GlideRecord("sys_audit");
rs2.addQuery("documentkey", data.sys_id.toString());
rs2.addQuery("tablename", data.table.toString());
rs2.addQuery("fieldname", "IN", fieldTypes.join(","));
rs2.orderByDesc("sys_created_on");
rs2.query();
while (rs2.next())
{
var fl = rs2.fieldname.getDisplayValue();
both getvalue and getdisplay value are returning the system name rather than the friendly name.
What I mean by this is, it is returning "reopened_by" instead of "Last Reopened By"
Any idea how I get the latter?
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2022 12:49 AM
For some reason gr.fieldname.getDisplayValue() gives me still the technical name and not the Display Value. Any idea why?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 08:53 AM
Hi,
The getValue() and getDisplayValue() will not give you the field label but the value itself so e.g. if this a reference to sys_user table than getValue() will give you sys_id of the user and getDisplayValue() will give you full name. You should use the getLabel() method:
gr.number.getLabel(); // replace number with your column name
Hope this helped.
Best regards,
Łukasz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 09:02 AM
I think i may of not made it entirely clear
In the sys_audit table the is a field/column called "Field Name" which has a value in the example of "reopened_by"
however if you click into that record their is a drop field called "Field Name" with a currently selected value of "Last reopened by"
What i want returned is this value, i want the "Last reopened by"
This is the same field (as far as i can tell) but it has two different display values and i'm not sure how to get this second value?!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 10:06 AM
If I understand you, what you want is to return the value of the "field" saved in the "field_name" field, so ....
DOC info
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_ScopedGlideRecordGetValue_String
var gr = new GlideRecord('incident');
gr.orderBy('number');
gr.query('active','true');
gr.next();
gs.info(gr.getValue('number')); <---- get info about 'number' field
in your case you need to do someting like this...
var fl = rs2.info(rs2.getValue('fieldname'));
please try and tell me how it turned out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2019 03:54 AM
I might be using it wrong but it does not seem to work. I don't appear to be getting any value using this.