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.

Restrict the record producer for all the contact of an account.

gagan12
Tera Contributor

I want a record producer(say Create Case) to not available for all contact of an Account if a check box (say allow case creation) is uncheck on account record.

 

Thanks'

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@gagan12 

you can use user criteria with advanced script and then add this in Available for related list of that record producer

1) get logged in user's account

2) query account table with this account and check the flag

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar ,

Thanks for your response, I am using the below script but even if checkbox (allow case creation) is true then also the user/contact are not able to view record producer(create case).(I want to restrict only when check box is false).

 

var contactRef= gs.getUserID().account;
var accountGr= new GlideRecord('customer_account');
accountGr.addQuery('u_case_creation_allowed', false);
accountGr.query();
 while(accountGr.next()){
    if(accountGr.name == contactRef){
        answer = false;
    }
}
 
Thanks

Hi,

What's the default return value of answer in your code. 

check the first line , if it's there in your code.

answer = true;
var contactRef= gs.getUserID().account;
var accountGr= new GlideRecord('customer_account');
accountGr.addQuery('u_case_creation_allowed', false);
accountGr.query();
 while(accountGr.next()){
    if(accountGr.name == contactRef){
        answer = false;
    }
}

 

-Thanks

Ashish


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

gagan12
Tera Contributor

Hi,

after adding 'answer = true', it giving the same response.

I am using this in 'Not Available' related list user criteria and default answer is true.