- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:10 AM
I want to send a notification to users who are inactive for 25 days and the role should be itil and the group should not be custom group(group name). I have checked the condition for role but I could not put a condition to check the group name in addEncodedQuery(). Can anyone resolve this issue.
gr.addEncodedQuery("roles=itil^active=true^last_login_timeRELATIVELE@dayofweek@ago@1");
I wanted to put a condition for group
eg:
group not equal to test_group.
Can anyone help me to put the correct condition
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:58 AM
How are you using the result? If you want to use the user's sys_id remember that when you query the sys_user_grmember table then if you will use gr.sys_id it will give you the sys_id of a connection record so it will be not the User's sys id.
To use the user's sys_id you should do gr.user.sys_id
In overall if you need to access user fields when you query sys_user_grmember table you need to dot walk to this field.
e.g.
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('user.last_loginRELATIVELT@dayofweek@ago@25^user.roles=admin^user.active=true^group.name!=Team Development Code Reviewers1');
gr.query();
while (gr.next()){
gs.print(gr.user.sys_id); // print the user's sys_id
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:20 AM
Hi Ajith,
Can you share your script here?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:22 AM
gr.addEncodedQuery("roles=itil^active=true^last_login_timeRELATIVELE@dayofweek@ago@25");
this is the script for that condition I have used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:29 AM
Hi Ajith,
the glide record object belongs to sys_user table it seems and information for user and group membership is stored in sys_user_grmember table
from there you can add group name query as well and the above query as well
I assume gr is glide record of sys_user_grmember table so here is the updated query condition
gr.addEncodedQuery("user.roles=itil^user.active=true^user.last_login_timeRELATIVELE@dayofweek@ago@1");
gr.addQuery("group.name", "yourGroupName");
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 03:36 AM
I Used
gr.addQuery("group.name", "yourGroupName");
The Notification is not sending to the User in that group with the itil role.