Group member should assign as per round robin

Ankita dhavale
Tera Contributor

Hi ,

 

I want to assign group member as per caller location in round robin manner .

There are two users in the group , I have created after Business rule for this 

 

(function executeRule(current, previous /*null when async*/ ) {
 
    // Add your code here
 
    var gr = new GlideRecord('incident');
    gr.addEncodedQuery('category= new^subcategory= invoice^caller_id.u_user_country=9138b7111b121100763d91eebc0713f6^ORcaller_id.u_user_country=8938b7111b121100763d91eebc0713ec^ORcaller_id.u_user_country=0938b7111b121100763d91eebc0713eb^ORcaller_id.u_user_country=c938b7111b121100763d91eebc0713eb^ORcaller_id.u_user_country=4938b7111b121100763d91eebc0713ed^ORcaller_id.u_user_country=4d38b7111b121100763d91eebc0713eb^ORcaller_id.u_user_country=0938b7111b121100763d91eebc0713f0^assigned_to=730397d41b4e5910ae993325464bcb7d^ORassigned_to=7d0177031b56dd50ae993325464bcbbc');
  
gr.orderByDesc('sys_created_on');
    gr.query();
    if (gr.next()) {
        gs.info('client invoice ');
        if (gr.assigned_to == '730397d41b4e5910ae993325464bcb7d') { 
            gs.info('second user');
            current.assigned_to = '7d0177031b56dd50ae993325464bcbbc';
 
        } else if (gr.assigned_to == '7d0177031b56dd50ae993325464bcbbc') {
            gs.info('first user');
            current.assigned_to = '730397d41b4e5910ae993325464bcb7d';
        }
    } else {
        gs.info(' user');
        current.assigned_to = '730397d41b4e5910ae993325464bcb7d';  //first user
 
    }
    current.update();
   
})(current, previous);
 
 
When I impersonate any new caller , it goes to the else part every time only and it return 1st users . 
Expected --> Any user submit ticket ,It should assign as per round robin not only to the first person. 

 

3 REPLIES 3

Claude DAmico
Kilo Sage

You are saying else so I'm ignoring the else if part. That being the result in all cases, your aren't getting anything back in your query. Copied that to a notepad and see there is a space after subcategory= and looks like the invoice to the end ended up on another line. Is that it?

Claude E. D'Amico, III - CSA

@Claude DAmico , Query is working fine , I have checked that.

Rahul Talreja
Mega Sage
Mega Sage

Hi @Ankita dhavale ,

Can you try with 

gr.getValue('assigned_to')=='xxxxxxxxxsysIDxxxxx';

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul