47 votes
Accepted

Assigning permission set to user in apex

Turns out it's very easy: PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = myPermissionSetId, AssigneeId = myAssigneeId); insert psa;
user avatar
  • 9,426
33 votes
Accepted

How can I assign a permission set to a user in a test context?

This question is marked as unanswered, despite it was answered in the comments. Let's revise the answer here: PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = '<required permission ...
user avatar
  • 13.2k
31 votes

Salesforce bug enabled "Modify All"

You can easily check all of your profiles by clicking on "Your Name" > Developer Console > Query Editor, and using the following query: SELECT Profile.Name, PermissionSet.Label FROM PermissionSet ...
user avatar
  • 429k
16 votes
Accepted

Exclusive differences Profiles vs permission sets?

As far as i know anything you can do w permission sets you can do w profiles, but there are a few things that can as of now only be done w profiles. The key UI difference in my experience is that only ...
16 votes

Salesforce bug enabled "Modify All"

From Salesforce Trust @ 5/17 12:56 pm: The Salesforce Technology team is investigating an issue impacting Salesforce customers who use Pardot, or have used Pardot in the past. The deployment of a ...
user avatar
  • 8,532
15 votes

Exclusive differences Profiles vs permission sets?

What permission sets allow you to do is minimize the number of profiles that you have to create. It also allows you to temporarily add and remove permissions for users without needing to change their ...
user avatar
  • 40.3k
12 votes
Accepted

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id: []

You can use userRecordAccess object to check CRUD permissions.. So pass the recordId and userId.. to check that user having what type of access on that record.. you can check variables like ...
user avatar
10 votes

MIXED_DML_EXCEPTION when creating PermissionSetAssignment in test class

We get this error when we are trying to perform DML on setup and non-setup objects in the same transaction. Try to use System.runAs() in your test class code Try to use this code: System....
user avatar
10 votes

Packaging system permissions in permission sets

As outlined in the documentation, you may only package the following permission set items: Custom object permissions External object permissions Custom field permissions Custom permissions ...
user avatar
  • 429k
10 votes
Accepted

Spring 22 testmethod GACK when assigning a PermissionSet to a newly-created user

Fixed - This will be handled by Spring '22 Patch 4.6. Update: There is now a Known Issue - Test classes are failing with Salesforce Internal Server Error. The workaround listed is to update the ...
user avatar
9 votes
Accepted

Managed Package Validation Error

Adam Torman's answer to a somewhat related (but not entirely) question notes: We do intentionally block the setting of parent permissions if it's a standard object By granting any access to a ...
user avatar
9 votes
Accepted

How to get list list of flows accessible by a User based on Permission Sets?

In short: I managed to do this in Apex by using apex-mdapi AFTER I updated the code to support flowAccesses. - here's the github commit with changes needed to support it. This is the only way I can ...
user avatar
8 votes

How can I assign a permission set to a user in a test context?

In addition to @patiatus answer.... Should you need to setup a custom permission without needing to care about what permission set it belongs to .... // Given user User userWithCustomPermission = new ...
user avatar
  • 61.4k
8 votes
Accepted

Query on permission sets held by a user

How PermissionSet relates to User is illustrated in this User, Sharing, and Permission Objects ERD. So for example, this SOQL will list all permission set assignments: select Assignee.Name, ...
user avatar
  • 129k
8 votes
Accepted

Query Object Access by Profile

Profiles are replicated into a special type of PermissionSet. IsOwnedByProfile will be true, ProfileId will be set to the Profile's Id field. So, you can query PermissionSet to determine a profile's ...
user avatar
  • 429k
8 votes

Salesforce bug enabled "Modify All"

As of 3 PM CDT. This is something I got to hear around from my colleagues who were part of the webinar that Salesforce had around this issue. The issue seemed to have affected DR sites as well, so ...
user avatar
  • 28.9k
7 votes

Tab Settings Not Available on Permission Set

I encountered same issue. And the solution which worked for me was that while creating the permission set I was not selecting any User License in the picklist. I created a new permission set with User ...
user avatar
  • 86
7 votes
Accepted

How to know if a field is part of a compound address field and thus is not permissionable

There is an easy way to determine if field is a real field or a part of compound field. There are two tables in Salesforce which correspond to compound fields and its components. If a field can be ...
user avatar
  • 13.2k
7 votes
Accepted

Permissions & Settings in Profile and Permission Set and its Usage

The Rule of thumb is permission set extend the access of profile and do not restrict. 1.In first scenario since profile already has access which means permission set cannot disable as permission sets ...
user avatar
7 votes
Accepted

How is Permission Set Metadata Deployment changing in Summer '17 (API 40.0)?

By fully retrieving all permissions all the time, it will avoid the various Bad Things that happen when you only retrieve a partial package. This would lead to the XML file spuriously growing very ...
user avatar
  • 429k
7 votes
Accepted

Get all field level permission from SOQL for an permission set

As mentioned by @benahm, SOQL on FieldPermissions retrieves only enabled field permissions for the permission set. Furthermore, as per chapter "Special Properties for Field Permissions" in ...
user avatar
  • 3,205
7 votes
Accepted

Can't assign permission set to my user after installing Salesforce Data Mask!

It was not really clear from the announcement or from most of the documentation, but Salesforce Data Mask is actually a paid feature, and if you want to use it you need to talk to your Account Execute ...
user avatar
6 votes
Accepted

System Admin is API user only, no security token

Force.com IDE Sometimes, you can still login with the Force.com IDE. It doesn't hurt to try. If you can, you can then download the admin profile, update the settings, and you'll be good to go. Make ...
user avatar
  • 429k
6 votes

Permission Set - Deciding correct components

You need to give access to visualforce page only. As per the docs: Once users can access a page, they can execute all Apex that’s associated with the page. This includes: The controller for the page ...
user avatar
  • 1,792
6 votes

How to resolve an "Unknown user permission: SendExternalEmailAvailable" deployment error

This relates to the "Send through External Email Services" setting in Setup. Go to Setup > Email Administration > Send through External Email Services to see the setting. According to the description ...
user avatar
  • 2,012
6 votes

How to resolve an "Unknown user permission: SendExternalEmailAvailable" deployment error

Set Email Deliverability to 'All Email': For unknown reason Salesforce automatically creates and removes this permission completely behind the scenes on all profiles based on the value of this ...
user avatar
  • 543
6 votes
Accepted

"Your account has been disabled" error message

I spend some time digging deep into why I could not assign a Permission Set to multiple users within my DE org (Developer Edition) to come to the realization that these users were inactive within the ...
user avatar
  • 4,654
6 votes

A good explanation for roles/profiles/permission sets and sharing

You can check this link http://hellosnl.blogspot.com/2017/08/salesforce-security-concepts.html Also check this image
user avatar
  • 1,232
6 votes

Hide Field within Permission Set

Permission sets are not used to prevent access to fields, to do that go to the profiles for the relevant users and untick access on there. Then use the Permission Sets to give access to the other ...
user avatar
  • 5,038
6 votes
Accepted

Possible reasons why a quick action button is not shown for a non-admin user?

Why would a user not see Global or Quick Actions? Despite the User being assigned a Page layout with Global or Quick Actions selected to display, they cannot see them in the Feed. This can ...
user avatar
  • 12.6k

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