Ref qualifier for type Field name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2022 02:42 AM
I have a field of type field name which is dependent on another type of type table. How can I show only those fields which are references to the user table only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2022 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2022 07:59 AM
Whatever you are showing is already done. My question is after this part. Field field as per your screenshot should only show Manager field since its referenced from user field.
I want the field type field to show only those fields which are referenced to sys_user field - like Manager, Assigned To, Managed By, Owned by etc. nothing else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2022 01:39 AM
In that you need to use attributes 'fieldChoicesScript' to get selected fields as per your need.
Create a script include and pass name of script include to this attribute.
Your script include script would be like below:
var GetUserTableReferenceFields = Class.create();
GetUserTableReferenceFields.prototype = {
initialize: function() {},
process: function(tableName) {
gs.info('Table Name '+tableName);
var result = [];
var ele = '';
var gr = new GlideRecord('sys_dictionary');
gr.addQuery('internal_type', 'reference'); //apply query internal_type=reference^reference=sys_user
gr.addQuery('reference', 'sys_user');
gr.addQuery('name',tableName).addOrCondition('name','task');
gr.query();
while (gr.next()) {
ele = gr.element + '';
result.push(ele);
}
return result;
},
type: 'GetUserTableReferenceFields'
};
Make sure to pass 'GetUserTableReferenceFields' to the attribute like below and make dependednt on table name type fields:
fieldChoicesScript=GetUserTableReferenceFields
Thanks,
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 01:29 AM - edited 05-27-2025 01:30 AM
Thanks for the answer, this was helpful.
I adjusted the process function so that it shows all reference fields from the table itself or its parent tables:
process: function(tableName) {
var referenceFieldNames = [];
var tableHierarchy = new GlideTableHierarchy(tableName);
var grDictionary = new GlideRecord('sys_dictionary');
grDictionary.addQuery('internal_type', 'reference');
grDictionary.addQuery('name', 'IN', tableHierarchy.getTables());
grDictionary.query();
while (grDictionary.next()) {
referenceFieldNames.push(grDictionary.getValue('element'));
}
return referenceFieldNames;
},