How can I give access to a Record producer to the manager

jkhanddh
Tera Contributor

Hello Everyone,

Help me with this!
Scenario: Employees of a particular country have access to a record producer, but there are employees whose managers are not from that country but they need access to this country. I can give access via static conditions but I want this to be dynamic. Can someone body let me know how to achieve this.

Thank you

2 REPLIES 2

Tanushree Maiti
Kilo Patron

Hi @jkhanddh 

 

  • Navigate to User Criteria: Go to Service Catalog > Catalog Definitions > User Criteria ->lick New.
  • Name the Criteria: Give a proper name
  • Enable Advanced: Check the Advanced check box.
  • Add the Script: In the Script field, use the following code to check if the user OR their manager belongs to the specified country //modify it as per your requirement

 

answer = checkAccess();

function checkAccess() {
var countryCode = 'IN'; // Change this to your target country as per your requirement
var userId = gs.getUserID();

var userGr = new GlideRecord('sys_user');
if (userGr.get(userId)) {

if (userGr.location.country == countryCode) {
return true;
}

if (userGr.manager) {
var managerGr = new GlideRecord('sys_user');
if (managerGr.get(userGr.manager)) {
if (managerGr.location.country == countryCode) {
return true;
}
}
}
}

return false;
}

 

Add this user criteria in Available for of  your Record producer.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

AndersBGS
Tera Patron

Hi @Tanushree Maiti 

 

What not provide access through group instead of direct access

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/