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
‎11-26-2019 12:11 PM
I am trying do do the same but with the "element" field on the "sys_journal_field" table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2019 04:32 AM
Unfortunately I did not, I instead created a work around, for some specific fields i renamed them completely and others i used a replace.
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())
{
// TEST USER'S ABILITY TO SEE WORK_NOTES - IF THEY CAN'T, AND THIS IS A WORK_NOTE, SKIP IT!
if (rs2.fieldname.getValue().toString() == "work_notes" && !hasItilRole && !isInWorkNotesList)
continue;
// SKIP BLANK UPDATES - PUT IN PLACE AS CLOSE NOTES UPDATE TO BLANK WHEN INCIDENT REOPENED
if (rs2.newvalue.toString() == "")
continue;
// TIDY UP NAMES AS DISPLAY VALUE STILL SHOWS VALUE OF FIELD NAME WITH UNDERSCORES
var flvalue;
if (rs2.fieldname.getDisplayValue() == "reopen_count")
var flvalue = "incident reopened";
else
var flvalue = rs2.fieldname.getDisplayValue().toString().replace("_"," ");
I hope this helps a bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2019 08:10 AM
Thanks for your reply, nice touch.
I figured out that the issue is with the "Short Field Name" field type because in my case I wanted to use such a field value to test a condition but it never worked.
What actually surprises me is that, contrary to you, I do need to use technical value for my condition and I manage to get the value. However, the script fails to test the "Short Field Name" value.
There is no information about the "Short Field Name" field type online so I just created two different business rules, building my condition with the native condition builder which actually solves my problem.
