- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2022 04:38 AM - edited 10-29-2022 04:45 AM
Hi
We have a requirement to delete the users from specific groups who are not logged in for 90 days along with notification, before removing them from the groups needs to send reminder notifications .
I have written scheduled job to check logged in user by gliding sys_user table and comparing today and last login date of users for this requirement
But in my script g's.getUserID() is not working,
Suppose if I hardcode the user sys id then both schedule job and email script s are working as expected.
Can anyone please suggest an alternative method to check the logged in user in both scheduled job and email script.
Thanks,
Anusha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2022 05:35 AM
You want to remove the users who have not logged in then by which logic are you using gs.getUserID();
This only returns the sys_id of current logged in users.
If I understand correctly you need to follow below:
1. Run a scheduled job and get the sys_id of users ( comma separated or in array) based on last login, then you can fire an event which can fire your notification to those users, you can pass the users in the event parameter . use gs.eventQueue() to fire event.
2. After this you can run deletion logic of these users from groups, you will need to delete the users from "sys_user_grmember" table.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2022 04:58 AM
gs.getUserID() will never work in schedule job because schedule jobs are run by system administrators or the user defined in "Run as" field.
The solution here could be to first fetch the users you want to fetch in an array or comma separated list and then remove them or send them notifications.
Please feel free to mark the answer correct / helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2022 05:15 AM
Hi Raghav,
It is difficult to fetch users as the validation is for 28 groups and almost 300+ users from these users.
Please provide your inputs If I follow below approach will helps?
1. if we call script include from schedule job and same validation for loggedinuser using gs.getUseID().
2.And I need to do same kind of validation in email script to show the removed users with group names.
Can you please help is there any way to check current login user in email script
Thanks,
Anusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2022 05:35 AM
You want to remove the users who have not logged in then by which logic are you using gs.getUserID();
This only returns the sys_id of current logged in users.
If I understand correctly you need to follow below:
1. Run a scheduled job and get the sys_id of users ( comma separated or in array) based on last login, then you can fire an event which can fire your notification to those users, you can pass the users in the event parameter . use gs.eventQueue() to fire event.
2. After this you can run deletion logic of these users from groups, you will need to delete the users from "sys_user_grmember" table.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:57 AM
Thanks Raghav.