- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:01 PM
Hello everyone!!
I have a 'Load Incident' reference field on 'Incident' table that references 'Load Incidents' (custom) table, which has other information in addition to a reference to 'Incident' table. I want the 'Load Incident' reference field to be populated with the Load incident record that points to current incident. I used this code in Fix Script to update all incident records.
var gr = new gliderecord('incident');
gr.query();
while(gr.next()){
var grr = new GlideRecord('u_load_incidents');
grr.addQuery('u_incident', gr.getUniqueValue());
grr.query();
while(grr.next()){
gr.u_load_incident = grr.u_incident;
gr.update();
}
}
It worked fine and the reference field is populated with the right value. But the value is not being displayed, both in List View and in Form view, although the value is stored. I can see the info icon that shows the correct record, and even when I display the value using form javascript alert, it displays correct value. But it is not being shown. What am I doing wrong?
When I click the info icon next to Load Incident, here's where it's taking me.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:10 PM
Veena,
There are few syntax errors. Your script should be this
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
var grr = new GlideRecord('u_load_incidents');
grr.addQuery('u_incident', gr.getValue("sys_id"));
grr.query();
while(grr.next()){
gr.u_load_incident = grr.getValue("sys_id");
gr.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:09 PM
Hi Veena,
What is the display field set on the u_load_incidents table?
From the Load Incidents form, right click the header and say Configure> Dictionary and see which field has the value true in the Display column.
Also, double check your ACLs to ensure you have read access on the entire table as well as all the fields on u_load_incidents.
System Dictionary - ServiceNow Wiki
Using Access Control Rules - ServiceNow Wiki
Security Best Practices - ServiceNow Wiki
Contextual Security - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:14 PM
Hi Chuck,
The display value is set correctly to incident reference field. And the ACL's aren't blocking me either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:10 PM
Veena,
There are few syntax errors. Your script should be this
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
var grr = new GlideRecord('u_load_incidents');
grr.addQuery('u_incident', gr.getValue("sys_id"));
grr.query();
while(grr.next()){
gr.u_load_incident = grr.getValue("sys_id");
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:15 PM
Hey Abhinay! That worked perfectly! Thank you!
But I don't understand why mine was wrong. getUniqueValue() will return the sys_id of the record, wouldn't it?