Assigning group/role to customer of newly created case

aguanci
Tera Expert

Hi All,

 

Is it possible to assign a group/role to the customer of a new case? We are currently trying to accomplish this through a Business Rule. I think where we are getting mixed up is whether to code for Role or Group. 

 

Scenario:

  • Leave Administration team member navigates to Create New Case
  • Customer receives role 

 

Business Rule:

Table - sn_hr_core_case

When to Run - before insert when HR Service = Request for Leave

 

(function executeRule(current, previous /*null when async*/) {
   
    var gr = new GlideRecord('sys_user_grmember');
    gr.addQuery('user', current.subject_person);
    gr.addQuery('role', '24ee0a504798461092d34ab7536d4329'); //sysid of role
    if(!gr.hasNext()){
        gr.initialize();
        gr.user = current.subject_person;
        gr.role = '24ee0a504798461092d34ab7536d4329';
        gr.insert();
        }

})(current, previous);
1 ACCEPTED SOLUTION

Table - HR case
When to run: Before insert and HR service = whichever you are solving for
 
 
 
(function executeRule(current, previous /*null when async*/) {
   
    var gr = new GlideRecord('sys_user_grmember');
    gr.addQuery('user', current.subject_person);
    gr.addQuery('group', '09af97374767351092d34ab7536d439d'); // assignment group sysid
    if(!gr.hasNext()){
        gr.initialize();
        gr.user = current.subject_person;
        gr.group = '09af97374767351092d34ab7536d439d';
        gr.insert();
        }

})(current, previous);

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @aguanci 

 

Is the role required for time based or permanent. In new release SN introduced Time based Role assignment.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

aguanci
Tera Expert

Forgot to add - currently the BR adding an empty group to the user profile:

aguanci_0-1707924731525.png

 

Table - HR case
When to run: Before insert and HR service = whichever you are solving for
 
 
 
(function executeRule(current, previous /*null when async*/) {
   
    var gr = new GlideRecord('sys_user_grmember');
    gr.addQuery('user', current.subject_person);
    gr.addQuery('group', '09af97374767351092d34ab7536d439d'); // assignment group sysid
    if(!gr.hasNext()){
        gr.initialize();
        gr.user = current.subject_person;
        gr.group = '09af97374767351092d34ab7536d439d';
        gr.insert();
        }

})(current, previous);