The CreatorCon Call for Content is officially open! Get started here.

Select inactive users with last login of 20 days and 35 days

Adeshola
Tera Contributor

I have a requirement to select inactive whose last login was 25 days ago and 35 days ago. I have used the script below to meet try this requirement but it returns for someone whose last login is 20 days ago and when I changed the days to either 25 or 35 days it returns no value: 

 

var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('last_login!=NULL^active=true^locked_out=false^last_loginONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()');
gr.query();

while(gr.next()) {
    gs.print('Inactive User: ' + gr.name);
}
 
when I use the relative option such as 
last_login!=NULL^active=true^locked_out=true^last_loginRELATIVEGT@dayofweek@ago@25 it returns nothing.
 
Thank you
Sola
2 ACCEPTED SOLUTIONS

Uncle Rob
Kilo Patron

Have you manually checked to see if there are records that satisfy that condition?

View solution in original post

Hello @Adeshola 

 

Here is the updated script:

var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('last_login!=NULL^active=true^last_loginRELATIVELT@dayofweek@ago@251^locked_out=false^user_nameNOT LIKEadmin');//for 30 days just replace 25 to 30
gr.query();

while(gr.next()) {
    gs.print('Inactive User: ' + gr.name);
}

This works smoothly in my PDI. Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

Thank You
Juhi Poddar

View solution in original post

5 REPLIES 5

Uncle Rob
Kilo Patron

Have you manually checked to see if there are records that satisfy that condition?

I have a user that meets this requirement

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @Adeshola 

Please try the below script:

var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('last_login!=NULL^active=true^last_loginRELATIVELT@dayofweek@ago@25^locked_out=false');//for 30 days just replace 25 to 30
gr.query();

while(gr.next()) {
    gs.print('Inactive User: ' + gr.name);
}

This works smoothly in my PDI. Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

Thank You
Juhi Poddar

Thank you for the response. I I tried using the solution provided and the closest I got to the requirement is using the relative condition with after 25 days but it returns the admin account also. How can I return only user without the admin? Thank youLast login - after.jpg using 25 days beforeusing 25 days before