We’re rewarding the question askers & reputations are being recalculated! Read more.
7

Your code will look like this: List<GroupMember> members = [ SELECT Id, GroupId, UserOrGroupId FROM GroupMember WHERE GroupId IN (SELECT id FROM Group where Id = :groupId) ]; List<Id> ids = new List<Id>(); for(GroupMember member: members) { ids.add(member.UserOrGroupId); } List&...


7

that will do the trick. what you basically have to do is to traverse through the nested groups by self referencing the getGroupsForIds() method // return list of all groups the user belongs to via direct or indirect membership public Group[] getGroupsForUser(Id userId){ Set<Id> groupIds = getGroupsForIds(new Set<Id>{userId}); return [ ...


6

The reason that this is happening is because within your UninstallHandler, the user in context is a temporary user that is used when performing managed package operations. This user type is LicenseManager. I'm assuming for security purposes, they do not have access to many dml operations on setup objects. We tried a similar thing in our uninstall handler to ...


5

You can't really restrict access to view records based on record types from the profile level. if you think of Salesforce as a filing cabinet, each drawer is an object, within the drawer there are folders that group the records. Record Types are those folder. On the profile when you say user has record type x, y or z available to them it only means their ...


5

From my experience, accessing direct group members isn't too bad - you just iterate the group and for all user members just pull their details. If it is a group member, you just recursively call your function that iterates the group. Where things get really sticky is when you try to figure out the indirect members - I've found that when you start trying to ...


5

Since Role is mapped in user record so retrieve UserRoleId from User In the Group object , RelatedId field stores following types of values: Role RoleAndSubordinates Though Group can have other Type as follows which doesn't have RelatedId Organization Queue Regular So, final query will be like this SELECT Id,Name,DeveloperName,RelatedId,Type FROM Group ...


4

When Grant Access using Hierarchy is checked for custom object(For standard objects this is always checked) even if the record is private ,users higher in the role than the owner of the record still gets access to the records . A simple example can be assume opportunity is private OWD and you are Sales Rep owning an opportunity record ,you have your manager ...


3

I found a bug in your code. Please check it below. public static Set<id> GetUserIdsFromGroup(Set<Id> groupIds) { // store the results in a set so we don't get duplicates Set<Id> result=new Set<Id>(); String userType = Schema.SObjectType.User.getKeyPrefix(); String groupType = Schema.SObjectType.Group.getKeyPrefix(); ...


3

You can query Group Object directly for that [Select Id,Name from Group where RelatedId =:roleID]


3

Groups are associated with data visibility (roles, sharing etc.) whereas you're talking about field level security which is associated with profiles, so this approach won't work easily. You would have to either rely on page layouts or complex control through Apex, neither of which I'd recommend. What you should do is create a profile with the base level of ...


3

The answer seems pretty obvious. Your community users don't have access to the GroupMember object. I don't think it's possible to give them access to it. The only way would be to have your controller run without sharing.


3

I am assuming you know the Group Id(lets say your group name is MyCoolUsers). If not, you can query on Group object against the developername of the Group. Next, you need to query on GroupMember object and find out which all groups are part of this Group. Yes, the roles are stored as Groups in GroupMember. Bear with me, I will explain. SELECT UserOrGroupId ...


3

Public Group API Name is Group and to add members use GroupMember. In Dataloader, if Group does not display in the default list, check Show all objects to see a complete list of objects that you can access.


3

You can migrate the members of your group using dataloader or workbench. The object's data that you are going to be working with is GroupMember. You will export the Group Members from the source org and import that data into the target org. You may need to correct any User ID values in the resulting CSV that don't exist in your target org, but assuming that ...


3

Permissions through public groups or roles denotes Record Level Visibility or Access Rights either that could be read-only or read-write. Even record level access comes after having access to objects via profiles or permission sets. Refer this diagram So, for your use case it will be better to provide access through profiles if all the users of the same ...


3

Groups are a type of setup object in salesforce with special behavior. Can you try moving the group dml to a future method and see if that does the trick? I think the issue is that you're doing a delete on line 40, and then doing the insert. According to the documentation here's what they say about groups: You can only insert and update a group in a ...


2

I'm afraid I don't think you can access group through the global variables. Also the syntax would be interesting as one person can be a member of zero to many groups. If you are working in a VisualForce page then you can expose this information through a method. As you suggest you are working in formulas, this option is not available. One possibility you ...


2

The post install user is fairly restricted. This is not officially documented, but here's a related post with a lot of details on what the ghost user cannot access. Some suggest using the without sharing keyword to alleviate the issue but I'm not sure if it would help with access to Group.


2

You can do one thing. Write trigger on feeditem and get body of message then you can check if string contains you group name and profile is not matched. Then add error message. using trigger.New[0].addError();


2

A group consists of a set of users. A group can contain individual users, other groups, or the users in a particular role or territory. It can also contain the users in a particular role or territory plus all the users below that role or territory in the hierarchy. So if you want to share the records with other users (In different role or territory) you ...


2

To display Public groups in drop down list and in Available Public Groups list select one public group,then press List Users button. After pressing the List Users button, you will get the all Available Users associated with that groups as shown in below screen shot as well. Output: Code: Visualforce Page Code <apex:page controller="GroupsController"...


2

Realistically, no, you can't do this with a simple query, as it also includes the manager's manager, the manager's manager's manager, etc... Basically, you'd need a second query to get everyone's role and the the role's parent role, then iterate over all those values and recursively remove the managers. While you can do this, it is non-trivial, because we ...


2

You need to do a code search for them as well, as they can be referenced in Apex. Best practice is to query for them by DeveloperName because it is unique, but it would be wise to also look for reference to Name. Any such references would need to be wrapped in single quotes, so you would do a global search on 'My_Group_DeveloperName', for example.


2

Lookup filters can only filter fields on the related object. They can spider up multiple related records, but they can't do what you are looking for in terms of checking that user is in a public group. So you would need a field to flag this on user itself in order to filter lookup. Since you can't have triggers fire on public group membership, you could ...


2

You can't currently disable Grant Access Using Hierarchy for standard objects, so the correct answer is "b." If, at some point in the future, this changes, then "d" would become a possibility, but the question would require that that it explicitly calls out if Grant Access Using Hierarchies is enabled or not.


2

Salesforce doesn't allow to write a trigger on GroupMember object. You should write a batch class to see the changes in GroupMember record. There is an idea around this, you can vote for on that idea.


2

Buttons are part of page layout. Page Layouts are controller by record type and Profiles. Let's ignore record type for now. Thus if Profile for Group Members of A and B is ame, you won't be be able to achieve this requirement. Solution: Create 2 profiles, Group A profile and Group B profile. Create 2 Page Layouts- Group A Page Layout and Group B page ...


2

Yes it is absolutely possible to execute workflow rule after the trigger execution. Please read my blog post to understand the order of execution. There is an existing issue which states Workflow does not use current value for "Owner:Queue.QueueName" in recursive evaluation if Owner was changed in prior evaluation link Keep your eyes open for the ...


1

You can run a batch much more frequently than every day. I've run them as frequently as every 15 minutes without issue by calling System.scheduleBatch in the finish method. You should probably add some sort of Boolean flag to control chaining for ease of testing, and you wish to control that flag via Hierarchy Custom Setting. The basic idea is simply: ...


1

Yes, that is what that field does. I went through the UI and checked/unchecked it on a group, and the value of that field changed accordingly. DoesincludeBosses = true DoesincludeBosses = false


Only top voted, non community-wiki answers of a minimum length are eligible