I need to create a public group from 'Everyone' minus another smaller public group.

The public group 'Everyone' is created from everyone under Role CEO and Internal Subordinates. The smaller group is all users with Role 'X'.

Is there any way to create the group 'Everyone - X' by excepting (whether through Apex, API, Metadata, sorcery) Role 'X' from 'Everyone', while keeping the Public Group 'Everyone' intact, so as to maintain the membership automatically?


The difficulty is that if you set up the group manually/programmatically, you'd need to react every time a new role was added. If its a complex role hierarchy you stand a good chance of hitting governor limits, and if there's a lot of churn you'll need to find a way to trigger the recalculation.

The way I've handled this in the past is to re-organize the hierarchy - i.e. put role 'X' at the same level as the CEO, so that when you set up your group of CEO and internal subordinates, it is naturally excluded. I then maintain record visibility through sharing rules. Obviously this doesn't work if you are relying on 'my team' type functionality for reporting purposes.

Failing that, can you set up a group that includes all the roles (but not subordinates) above role 'X' until you hit the peer level, then include the role and subordinates of all peers? You'd still have to maintain this yourself, so if there's a lot of churn it might not be practical, but it would leave the platform doing most of the work.

  • I think you are onto something though, I didn't think to mess around with roles . There is a decent amount of churn so I think it should be avoided in our case, but what I think could be viable is to create a new unused role above the CEO to redefine the group 'Everyone' to include all users, make a new group 'Everyone under the CEO', and then manually have to admin public groups and roles for 'X'. That would take care of 170 of the 200 people in question automatically. Thanks! – Marv-o May 9 '13 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.