33
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 ...
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 ...
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 ...
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.
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 ...
9
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:
...
9
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 ...
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 ...
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
...
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 ...
7
votes
Testing with Community User, getNetworkId = null
When the Experience User is created given its profile, it is automatically assigned to the NetworkMember object
This is basically a junction object between the Network (Experience) and the User (...
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(...
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 ...
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 ...
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 ...
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 ...
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, ...
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, ...
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 ...
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);
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
...
5
votes
Accepted
Get account by user id
Looking at the User object fields in SFDC ,AccountId and ContactId fields are populated only if your user is a portal/community user
Also you can directly use the AccountId field instead of using ...
5
votes
How to query active users in particular profile?
You can simply use a count query:
Integer assignedUsers = [
SELECT count() FROM User WHERE IsActive = true AND ProfileId = '<profile_id>'
];
5
votes
Accepted
Generate new password and notify user immediately
By default, you cannot trigger the same email as Salesforce triggers in the scenario you mentioned. I have had a similar situation, which was resolved with coordination between IT and Business as we ...
5
votes
How to get remaining session time in Apex for current user
If you happen across the documentation on the AuthSession object, you'll get a helpful hint (emphasis mine):
LastModifiedDate
Type
dateTime
Properties
Defaulted on create, Filter, ...
5
votes
How can you access display languages via Apex?
I'm really interested in this topic too.
I contacted Salesforce Support with the same question and their answer was:
I tried Adrian's workaround:
Based on the documentation of the User object, ...
5
votes
Accepted
How do I run a flow as another user in a record-launched flow?
You can't get the Flow to execute as another User. You can make it run in system context in terms of Permissions and Level of access to Fields and Records, but you can't make it "impersonate"...
4
votes
Deleting Users from Salesforce permanently
Those who thinks that this Delete feature is required for Deleting unwanted user details from Salesforce please click on below Link to Vote for the Idea. Currently this Idea is under "PRODUCT TEAM ...
4
votes
Accepted
User Email and Username discrepancy
The phrasing "in the form of a valid email address" is somewhat ambiguous. Email address validation is notorious for being A) overly complicated and B) unreliable. The advised methodology for finding ...
4
votes
Accepted
IP Address Restrictions Other Than Profile-Based?
You can't have assign IP restrictions through Permission sets (or) Workflows or any other ways.
For your problem you have to assign a separate profile for the user is only the way.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
user × 630apex × 132
profile × 67
soql × 50
community × 47
user-management × 43
permissions × 37
trigger × 33
visualforce × 31
email × 28
user-record × 22
unit-test × 21
permission-sets × 19
licenses × 19
customer-community × 18
rest-api × 16
administration × 16
customer-portal × 16
userlicense × 16
query × 15
api × 14
visual-workflow × 14
email-template × 14
contact × 14
login × 14