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

schedule job to reomve inactive users from group .

raghuv
Giga Contributor

I want to create schedule job to remove inactive users from group

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Raghu,



How about something like this... Note this is not tested... Always backup your data (e.g. export the sys_user_grmember table to XML) before testing with the deleteRecord operation.



(function () {


var gm = new GlideRecord('sys_user_grmember');


gm.addQuery('user.active', false);


gm.query();


while (gm.next()) {


        gm.deleteRecord();


}


})();


View solution in original post

18 REPLIES 18

raghuv
Giga Contributor

you mean to say remove users if they are no more active in service now, this is good idea but we are not removing user if he is inactive in service now we just inactivate them.


Raghu,



I think what Chuck and Robbie were suggesting is that you create an after business rule, the conditions of which are the user is inactivating (however that process occurs). There you would remove the sys_user_grmember (Group membership table) records. This has the benefit of removing them from groups immediately after being inactivated, as opposed to waiting on a scheduled job.


oh my mistake taken that in wrong direction, but another twist in my requirement is I need to do this if user is till inactive still 28 day. means if user is inactive for 28 days remove him from all the group


Hi Raghu,



You can write a workflow , when a user is made inactive you can trigger this workflow keep a timer for 28 days, after 28 days check if user is still inactive then remove from all the groups. And for sys_user table you can make them locked out once they get in-active and mention userid as Userid-Disabled.


Hi Chuck,



                          What is your suggestion on this requirement need to remove users from group if he is inactive more that 28 days. what is you recommendation business rule, workflow or schedule job.