Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Conditional Reference Qualifiers

JonnyFoster
Tera Contributor

Afternoon everyone. 

 

Looking for a bit of help - I'm creating a new catalog item. We have a mandate that will only let our 'regular users' (i.e., not IT staff) managers have to request access for their staff for certain items, which I've achieved by putting on a reference qualifier on the requested_for variable (manager is (dynamic) me, or manager_manager is (dynamic) me) .

I need to be able to override this for my Service Desk team to be able to raise requests for anyone in the Business.

 

Is it possible to make the reference qualifier conditional at all?

 

Many thanks!

1 ACCEPTED SOLUTION

@JonnyFoster 

you can use advanced ref qualifier as this

-> if logged in user doesn't have itil role then it applies the reference qualifier and restricts the users

-> if logged in user has itil role then no query it means it will show all active users

javascript: var query = '';
if (!gs.hasRole('itil'))
    query = 'manager=' + gs.getUserID() + '^ORmanager.manager=' + gs.getUserID();
query;

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@JonnyFoster 

yes you can handle this using advanced ref qualifier

how are you identifying the Service Desk team?

share screenshots

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur

 

I can either do it by their department, or perhaps 'current signed in has ITIL' role. I have two fields on the form that will ultimately be hidden, and returns the person logged in currently javascript:gs.getUserID(); and then another field which dot walks their 'department', which is what I'd thought about using to provide the validation. This field is called 'current_signed_in' and the department is 'current_signed_in_department'. I need to allow 'IT Service Delviery' and 'Banking Systems' departments' access to raise the requests for anyone.

JonnyFoster_0-1763709281846.png

Does that make sense?

@JonnyFoster 

you can use advanced ref qualifier as this

-> if logged in user doesn't have itil role then it applies the reference qualifier and restricts the users

-> if logged in user has itil role then no query it means it will show all active users

javascript: var query = '';
if (!gs.hasRole('itil'))
    query = 'manager=' + gs.getUserID() + '^ORmanager.manager=' + gs.getUserID();
query;

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for the response, Ankur. That hasn't worked, unfortunately. Now, no reference qualifier is applied at all to anyone, regardless of them having an itil role or not. I copied and pasted your query as follows:

JonnyFoster_1-1763969126925.png