- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 10:48 PM - edited 09-26-2023 10:00 AM
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
please help
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 12:55 AM
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 09:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 09:33 PM - edited 09-26-2023 10:50 PM
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
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 12:55 AM
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:
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