How to achieve Advanced Work Assignment: Set Agent's Availability automatically after 10minutes

Research
Tera Guru

Hi Team

I want to set logged in users to Available - after 10minutes
with the reference of last login after 10minutes I want to set the status into Available in AWA (Advanced work Assignment).


Can any one guide me script 

Research_0-1695707184754.png

 @Maik Skoddow

please help

Thanks.

1 ACCEPTED SOLUTION

Hi @Research ,

 

Can u please try with the below code, I have updated the filter:

var users = new GlideRecord('sys_user');
users.addEncodedQuery('last_login_timeISNOTEMPTY^last_login_timeRELATIVELT@minute@ahead@10^last_login_timeONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');// add users to this filter as well who are suppose to be available(Who will be working on workspace)
users.query();
while(users.next()){
    var gr = new GlideRecord('awa_agent_presence');
    gr.addQuery('agent',users.sys_id);
    gr.query();
    if(gr.next()){
        gr.current_presence_state = '0b10223c57a313005baaaa65ef94f970';// Available state sys id present in awa_presence_state table
        gr.update();
    }
}

 The filter denotes:

DanishBhairag2_0-1695801125839.png

Please add relevant users (Agents who are supposed to be available) in this filter, so that whenever the code executes it will make only the people available who are suppose to.

 

Please mark my answer helpful & accepted if it helps you resolve your query

Thanks,

Danish

 

View solution in original post

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Research ,

 

U can try below logic in order to achieve your requirement.

 

var users = new GlideRecord('sys_user');
users.addEncodedQuery('last_login_time!=NULL^last_login_timeRELATIVELT@minute@ahead@10^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
users.query();
while(users.next()){
    var gr = new GlideRecord('awa_agent_presence');
    gr.addQuery('agent',users.sys_id);
    gr.query();
    if(gr.next()){
        gr.current_presence_state = '0b10223c57a313005baaaa65ef94f970';// Available state sys id present in awa_presence_state table
        gr.update();
    }
}

 

Please mark my answer helpful & accepted if it helps you achieve your fulfill your requirement

 

Thanks,

Danish

Research
Tera Guru

Hi @Danish Bhairag2 
Thankyou for the script
Its not working for me. we are near to solution
(created BR when to run after, with no condition, table sys_user)

I think in script 6th line should be modified 
Can you guide me in detail pls

Research_0-1695793803294.png

 

Thanks

Hi @Research ,

 

Can u please try with the below code, I have updated the filter:

var users = new GlideRecord('sys_user');
users.addEncodedQuery('last_login_timeISNOTEMPTY^last_login_timeRELATIVELT@minute@ahead@10^last_login_timeONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');// add users to this filter as well who are suppose to be available(Who will be working on workspace)
users.query();
while(users.next()){
    var gr = new GlideRecord('awa_agent_presence');
    gr.addQuery('agent',users.sys_id);
    gr.query();
    if(gr.next()){
        gr.current_presence_state = '0b10223c57a313005baaaa65ef94f970';// Available state sys id present in awa_presence_state table
        gr.update();
    }
}

 The filter denotes:

DanishBhairag2_0-1695801125839.png

Please add relevant users (Agents who are supposed to be available) in this filter, so that whenever the code executes it will make only the people available who are suppose to.

 

Please mark my answer helpful & accepted if it helps you resolve your query

Thanks,

Danish