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

I think the condition should revers because "Not Available For" applied when its condition it true

so change the return value. 

answer = false; // false means not avialble for condition not applied
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 = true; // condition applied
    }
}

 

-Thanks,

AshishKMishra

Please accept solution and mark helpful if it helps you


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

@gagan12 

try this

var contactRef = gs.getUser().getCompanyID();
var accountGr = new GlideRecord('customer_account');
accountGr.addQuery('sys_id', contactRef);
accountGr.addQuery('u_case_creation_allowed', true);
accountGr.query();
answer = accountGr.hasNext();

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

AshishKM
Kilo Patron
Kilo Patron

Hi @gagan12 ,

You can create user criteria and configure the record produce for "Not Available For"

 

AshishKMishra_0-1699536678544.png

 

-Thanks,

Ashish

 


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