- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 12:50 AM - edited 12-28-2022 12:50 AM
for below script we are getting error like below.
Evaluator: com.glide.script.RhinoEcmaError: "event" is not defined.
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", event.parm1);//this line not working
//gr.addQuery("sys_id", "3883f4c0730123002728660c4cf6a754");//working but only one record is updating..
gr.query();
if (gr.next()) {
gs.info("User is deactivated" + gr.user_name);
gr.active = false;
gr.update();
}
can any one help me for this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 03:46 AM - edited 12-28-2022 03:47 AM
For Script action --Deactive User set action name=deactivate_user..
It will deactivate your user which were not logged in from 85 days.
once changes are done please go to Schedule Job and use UI action Execute now to check the user are getting deactivated .
Hope this helps.
Regards,
Hemant
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 04:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 01:02 AM
Hi @Dinesh ,
As event.parm1 is not defined in background script.
So your getting error.
Regards,
Hemant
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 01:11 AM
Hi @Hemant Goldar ,
I am using script from below link.. even it is not working when event is triggered.but notifications are triggering correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 01:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 02:00 AM
User Deactivate after 85 days and send an email to the user before deactivate:
Notify users 85 days and deactivate
Scheduled job
var gr = new GlideRecord("sys_user");
gr.addActiveQuery();
gr.addQuery("last_login",'<=',gs.daysAgo(85));
gr.query();
while(gr.next()) {
gs.eventQueue('user_not_logged_in_85days_ago', gr, gr.getValue("email"));
gs.eventQueue('deactivate_user', gr, gr.getValue("sys_id"));
}
event registry:
script actions
Name: Deactive User
var gr = new GlideRecord("sys_user"); gr.addQuery("sys_id",event.parm1); //gr.addQuery("sys_id", "8ff5b254b33213005e3de13516a8dcf7"); gr.query(); if (gr.next()) { gs.print("User is deactivated"+gr.user_name); gr.active=false; gr.update(); }
notification: