31 votes
Accepted

SOQL to find All Users with a Custom Permission

Update Please note that for the running user, you can use the FeatureManagement class: Boolean isEnabled = FeatureManagement.checkPermission('My_Permission_Api_Name'); Surprisingly, I don't think ...
Adrian Larson's user avatar
  • 150k
25 votes

Automated Process User Profile Permissions

I've found Matt's answer on the IdeaExchange You can follow the recommendation from Roy Lloyd and create a Permission Set and assign the autoproc User in Exec-Anonymous: insert new ...
Steven.B's user avatar
  • 500
19 votes
Accepted

Is Username Globally Unique?

Salesforce is split across login "domains." Each domain uses its own username index, which means it's entirely possible to create the exact same user on login.salesforce.com, test.salesforce.com, and ...
sfdcfox's user avatar
  • 491k
13 votes
Accepted

Deleting Users from Salesforce permanently

As of today, there's still no way to do that. You can, however vote on this idea, that's currently on review.
Fernando Gavinho's user avatar
10 votes

How can you access display languages via Apex?

Based on the documentation of the User object, if you remove a language from the Displayed Languages, the corresponding PicklistEntry becomes inactive. Based on my experimentation, this appears to ...
Adrian Larson's user avatar
  • 150k
8 votes

APEX test user creation

Building on this answer, I construct my test classes @TestSetup methods such that I can create an arbitrary number of unique users using a shortened 8-char GUID to init the names and emails, like so: ...
Shanerk's user avatar
  • 1,067
8 votes
Accepted

Retrieving the profile photo for a user

Use user's FullPhotoUrl and SmallPhotoUrl fields VF code: <apex:page controller="cls_PhotoUrl"> <apex:form> <apex:image value="{!...
Ratan Paul's user avatar
  • 22.7k
8 votes
Accepted

Formula Specific to Running User?

There are a few approaches you can take here, which I will list in order of preference. These should work just about anywhere merge fields can be used. Create a Custom Permission You can check if ...
Adrian Larson's user avatar
  • 150k
8 votes

Mixed DML operation error

You must specify UserRoleId as null. Reference: You can insert a user in a transaction with other sObjects in Apex code saved using Salesforce API version 15.0 and later if UserRoleId is specified ...
Adrian Larson's user avatar
  • 150k
8 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 ...
Mohith Shrivastava's user avatar
8 votes
Accepted

How can I delete a contact which was associated with a customer portal user?

Just to add to @John Thompson's answer, you can add the button that disables the customer user: This will remove the connection between the user and the contact, and mark the user as deleted. If you ...
Itai Shmida's user avatar
  • 5,025
8 votes

It is possible to clone a user in salesforce from exsting user?

It is possible. Please take a look at below link https://success.salesforce.com/answers?id=90630000000grMNAAY I did try this on my end by creating a custom link on User Object & it worked smooth ...
night crawler's user avatar
8 votes

In test class can see all org users in list

This is the expected behavior and is documented in the Isolation of Test Data from Organization Data in Unit Tests (emphasis mine): Starting with Apex code saved using Salesforce API version 24.0 ...
Jayant Das's user avatar
  • 30.6k
7 votes
Accepted

Is there a to check how many users using compact/comfy display density view?

You can query against the UserPreference object. Looking at the doc, you can see that density is stored as 108 in the Preference field and has been included since API 44. You can include tolabel(...
Kris Goncalves's user avatar
6 votes

Query all the queue a user belong

The Sobject you should query is GroupMember. But it have the membership details of both Queue and Public Group. So you need to differentiate it using the Group type as 'Queue'. Select Group.Name from ...
Vigneshwaran G's user avatar
6 votes
Accepted

License Limit Exceeded Error while creating user

There is no solution to this since you have consumed all the license that were allocated for your org . Deactivate the existing users if you are testing your code . You can also purchase additional ...
Mohith Shrivastava's user avatar
6 votes
Accepted

JSON.deserialize() for User records wont work

I was able to reproduce the issue in my DEV org by creating a class named User. Another class has following code: User user = (User) JSON.deserialize('{}', User.class); Which yeilds the same error ...
Raul's user avatar
  • 18.8k
6 votes
Accepted

SOQL returning incorrect value

This is a Known Issue that can occur. It goes way back to the days when the standard profiles were named PTX, where X was a number. They still occasionally end up showing up in odd places, and you've ...
sfdcfox's user avatar
  • 491k
5 votes

Freeze User through code and make report on them

Here is some sample code that I used to this: List<UserLogin> users = [SELECT IsFrozen,UserId FROM UserLogin WHERE UserId IN (SELECT Id FROM User WHERE Profile.Name != 'System ...
Force2b_Mike's user avatar
5 votes
Accepted

What is a 'CSS User'?

The Customer Self-Service ("CSS") user is used by the classic Self-Service Portal. It represents the customer who has logged in and is doing something with the case (e.g. logging the case, adding a ...
sfdcfox's user avatar
  • 491k
5 votes

Test coverage for a user trigger: How to prevent "DML not allowed on User" in test-class?

I don't know why, but all you need is to change upsert u; into insert u; update u; and all the pain goes away. You can save without any problem and the coverage is there. I found this ...
Uwe Heim's user avatar
  • 28.4k
5 votes
Accepted

Can I assign Permission set to a profile instead of user?

We can not able to assign Permission set to Profile. We need to assign it to a User only. A permission set is a collection of settings and permissions that give users access to various tools and ...
Devendra's user avatar
  • 5,075
5 votes

Can I assign Permission set to a profile instead of user?

AFAIK the platform has no direct support for this. But you can write workflow logic or trigger code to add/delete the PermissionSetAssignment objects automatically based on attributes of the User ...
Keith C's user avatar
  • 136k
5 votes
Accepted

User Licenses Remaining?

We have a UserLicense object in Salesforce, which stores all the license count information. Link to documentation: UserLicense object. Query: select Id, Name, UsedLicenses, TotalLicenses, Status, ...
Ysr Shk's user avatar
  • 3,157
5 votes
Accepted

Salesforce: Log in as other user

Please follow below instructions to Enable the "Organization Admins Can Login as Any User" feature: Enable the "Organization Admins Can Login as Any User" feature With this feature enabled, ...
sfdc's user avatar
  • 13.7k
5 votes
Accepted

SOQL - UserLogin relationship from User

Try a Left Inner Join: SELECT FirstName, LastName FROM User WHERE Id IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true) Also note that the query syntax returns a List<User>, and you are ...
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Remove items from list - mixed object

Use a Map instead. Then you can remove based on a key. Map<Id, User> newUsers = new Map<Id, User>(users.clone()); for (BCS__c record : findHubs) newUsers.remove(record.User__c);
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Query Author Apex Permission?

I just realized that my search for Author Apex on the PermissionSet fields missed one that is meant as a catch-all: Field Name PermissionsPermissionName Type boolean Properties Create, Filter, Update ...
Adrian Larson's user avatar
  • 150k
5 votes

Testing with Community User, getNetworkId = null

When the Community User is created given its profile, it is automatically assigned to the NetworkMember object This is basically a junction object between the Network (Community) and the User (...
cropredy's user avatar
  • 71.4k

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