- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-13-2022 11:18 AM
Hello,
As per the project implementation, I am trying to get all the incident column names in a custom list field. So that the user can select all the fields for those they want to get values from incident table.
with the code below (this I got from one of the community post) I can able to get only 21 incident fields. But I want the task fields on incident form as well (Number, Short description, Description, Assignment group etc.) Any help would be appreciated.
var arr_fields=[];
var gr = new GlideRecord('sys_dictionary');
gr.addQuery('name', 'incident');
gr.addActiveQuery();
gr.addEncodedQuery('internal_type!=collection^ORinternal_type=NULL');
gr.query();
gs.addInfoMessage("number of incident fields :" + gr.getRowCount());
while (gr.next()) {
arr_fields.push(gr.column_label.toString());
}
for(var i=0; i<arr_fields.length; i++)
{
gs.info(arr_fields[i]);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-13-2022 11:25 AM
Try below
var arr_fields=[];
var gr = new GlideRecord('sys_dictionary');
gr.addEncodedQuery('name=incident^ORname=task');
gr.addActiveQuery();
gr.addEncodedQuery('internal_type!=collection^ORinternal_type=NULL');
gr.query();
gs.addInfoMessage("number of incident fields :" + gr.getRowCount());
while (gr.next()) {
arr_fields.push(gr.column_label.toString());
}
for(var i=0; i<arr_fields.length; i++)
{
gs.info(arr_fields[i]);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-13-2022 11:25 AM
Try below
var arr_fields=[];
var gr = new GlideRecord('sys_dictionary');
gr.addEncodedQuery('name=incident^ORname=task');
gr.addActiveQuery();
gr.addEncodedQuery('internal_type!=collection^ORinternal_type=NULL');
gr.query();
gs.addInfoMessage("number of incident fields :" + gr.getRowCount());
while (gr.next()) {
arr_fields.push(gr.column_label.toString());
}
for(var i=0; i<arr_fields.length; i++)
{
gs.info(arr_fields[i]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-20-2022 05:58 AM
Hi There,
I am trying to show all the task and incident fields in a custom list type field. With the above code I am getting all the required fields in a comma separated array but I am facing challenges to populate the list type field. Whatever I am doing, the list type field which is reference to Dictionary entry is showing all the dictionary records instead of the only the task and incident fields. I should only get Task and Incident field to be selected on "Field" list. Any help would be much appreciated.
Below is my Script include:
List type field:
Output: