Announcing the Global SNUG Board of Directors. Learn more here
‎08-06-2020 08:54 PM
I have a couple of Reference Fields.If I click on the look up icon I want the data to be populated depending on some filters or query..and every user can see data depending on his category.
Solved! Go to Solution.
‎08-06-2020 09:26 PM
Reference Qualifier: - Reference Qualifiers are to create filters that restrict the data that is returned for a reference field. A reference field stores a link (reference) to a field on another table, making the records/fields in the referenced table available to the form containing the reference field.
How to Reach Reference Qualifier: - Open any Table of Your Choice: - Incident/Problem/Change.
Step 1:-Application Navigator>Incident>Open Existing Record or Create New.
Step 2:-Right Click on Any Reference Field i.e. Caller, Service, and Configuration Item.
Step 3:-Configure Dictionary.
change the simple to dynamic in your case.
Dynamic Reference Qualifier:-Dynamic reference qualifiers enable you to use a dynamic filter option to run a query against a reference field to filter the returned data set.
call this script include into your dynamic reference qualifier.perform this activity for each field of your choice.
department:function()
{
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
return "department"+"="+gr.department.toString(); }
},
refer the video
https://www.youtube.com/watch?v=6V1Vf-pk1wc&t=605s
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
‎08-06-2020 09:01 PM
Hi Sanket
what I have grasped is,do u want the data to be available as per the Logged in users department??
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
‎08-06-2020 09:08 PM
Yes
‎08-06-2020 09:15 PM
Hi Sanket Choughule
Try these in the Default value field for the Variables:
javascript:gs.getUser().getRecord().getValue('department');//actual name
Kindly Mark helpful and correct if it works.
Thanks.
‎08-06-2020 09:04 PM
Hi,
Use this clause in the reference qualifier.
javascript: gs.getUser().getDepartmentID();
For all the avaliable methods:
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
Thanks
Sudhanshu