I want to use a business rule to check if a user set in the user's reference type column has a speci

Takumi Togashi
Tera Expert

I want to use a business rule to check if a user set in the user's reference type column has a specific role.

 

1 REPLY 1

raj chavan
Tera Guru

Hi @Takumi Togashi 

 

   var user = current.your_reference_field; // 
   if (user) {
       var userGR = new GlideRecord('sys_user');
       if (userGR.get(user)) {
           if (userGR.hasRole('specific_role')) { 
               gs.addInfoMessage('The selected user has the required role.');
           } else {
               gs.addErrorMessage('The selected user does not have the required role.');
               current.setAbortAction(true); // Prevent the action (optional)
           }
       }
   }

 

 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj