reference qualifier

si21
Tera Guru

Hi experts,

We have 'requested for' variable on record producer and it should show users record based on logged in user.

1. if the logged in user is a manager, we need show only their direct reportees.

2. if the logged in user is HR, we need to show all users

 

How can we achieve this

3 REPLIES 3

_Gaurav
Kilo Sage

Hi @si21 

For this you can use script include in your reference qualifier like javascript: new yourscriptincludename().methodname();

 

In your script include, check if the logged-in user is the manager?
If yes return all the users where the manager is logged-in user
else
return all users

Please mark helpful if this resolves your query.
Thanks!

Amit Verma
Kilo Patron
Kilo Patron

Hi @si21 

 

You will need a Script Include and a reference qualifier for this. Refer https://www.servicenow.com/community/developer-forum/script-include-to-see-logged-in-user-is-an-mana... to get the reference for script include.

 

javascript: new yourscriptincludename().methodname(); syntax should be used for reference qualifier.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Anand Kumar P
Giga Patron
Giga Patron

Hi @si21 ,

Reference qualifier :javascript:new scriptincludename().scriptIncludeFunctionName()

Below script Include Code:

 

var mgr =  gs.getUser().getRecord().getValue('manager');
var a = new GlideRecord('sys_user');
                    a.addQuery('manager', mgr );
                    a.query();
                    var users = [];
                    while (a.next()) {
                        users.push(a.getUniqueValue());
                    }
                    return 'sys_idIN' + users.toString();

 

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand