BR to set user 'active' field to false if member of a certain group

StewartFletcher
Tera Expert

We are looking to try and set users 'active' field to false if they are part of a certain group.

 

However, it appears the sys_user table cannot see the Groups related list, meaning I think we'd have to script that somehow.

 

Done a lot of scouring and cannot see anything that points to a solution. I see things about checking if a user is in a group, but not then 'do this'. I'm very much a scripting novice

 

So essentially if user is member of 'test group', then set Active to 'false'

14 REPLIES 14

@StewartFletcher 

I think there's some other logic for locked_out which you will have to figure it out

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I think locked_out is a red herring. It's simply not putting active back to true.

@Ankur Bawiskar so more on this - it's not picking up that the group is being removed. I've tried before and after. Tried insert, update, delete. Tried Group 'is not', 'does not contain' 'changes' and 'changes from' but none of them trigger.

 

Only way it seems to work is setting 'changes to' or 'is' a different group.

Any more ideas? That script doesn't work for putting them back to active, because it doesn't seem to recognize a user being removed from the group.

 

Also when it's an LDAP import, this doesn't work at all.

StewartFletcher
Tera Expert

I simply need something that does the following.

 

If a user is added into a certain group, their account 'active' flag get unticked.

Then, if the user is removed from this group, their account 'actie' flag gets ticked again.

 

Yet there seems to be no way of easily doing this. I'm thinkig it needs to be a full on client script, but unsure how to go about it.