Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Regarding Reference fields

Sanket Choughul
Tera Contributor

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.

Ex.The caller field must show the data as per the logged in users department.
This must work on impersonation too.
Can I achieve this using OOB Functionality or can someone provide me how to do that.
1 ACCEPTED SOLUTION

Gaurav Shirsat
Mega Sage

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

View solution in original post

8 REPLIES 8

Gaurav Shirsat
Mega Sage

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

Yes

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.

Sudhanshu Talw1
Tera Guru

Hi,

Use this clause in the reference qualifier.

javascript: gs.getUser().getDepartmentID();

find_real_file.png

For all the avaliable methods:

https://www.servicenowguru.com/scripting/user-object-cheat-sheet/

 

Thanks

Sudhanshu