The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

24

Taken from the documentation: Generally, all Apex code runs in system mode, where the permissions and record sharing of the current user are not taken into account. The system method runAs enables you to write test methods that change the user context to an existing user or a new user so that the user’s record sharing is enforced. The runAs method doesn’t ...


19

The easiest way to do so is to not rely on the key prefix. Instead, just ask salesforce what the type is: if(lead.OwnerId != null) { // User is currently known if(lead.OwnerId.getSObjectType() == User.SObjectType) { // Owner is a user } else if(lead.OwnerId.getSobjectType() == Group.SObjectType) { // Owner is a group } } To use ...


15

Per the documentation: Global variables - $Api You can use this expression in your VF page markup. {!$Api.Session_ID}


13

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 prerellogin.pre.salesforce.com, and any other unique login domains that may exist. Note that "My Domain" does not constitute a unique login domain; it still ...


11

Customer Communities users do not have access to the full sharing model and therefore can't be added on a __Share record. The only way to share a record with a Customer Communities user is through Sharing Sets and Sharing Groups.


11

I would get the UserRole records you want first and then query the User records. Grouping UserRole Records by Parent // public with sharing class RoleHierarchy static Map<Id, List<UserRole>> hierarchy { get { if (hierarchy == null) { hierarchy = new Map<Id, List<UserRole>>(); for (...


10

I tried to relate API Name with UI label and here is what I found. Missing field in API but Available on UI Accessibility Mode NewsAllow Forecasting Color-Blind Palette on Charts End of day Force.com Flow User Force.com Quick Access Menu = Make Setup My Default Landing Page Mobile Configuration Mobile Push Registrations Receive Approval ...


10

As of today, there's still no way to do that. You can, however vote on this idea, that's currently on review.


9

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 you can do it more simply than the below. Execution public static List<User> getUsersWithCustomPermission(String name) { Set<Id> ...


8

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 someone has a Custom Permission in a formula as follows: $Permission.My_Custom_Permission__c Steps: Create Custom Permission Add it to a Permission Set Assign ...


8

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 Goto Setup-> Customise->Users-> Custom Links -> New Button or Link


6

So yes, typically Owner relates to the User obj, BUT it can also relate to the Group obj. There are a number of standard objects that have multiple Objects off Owner (kinda of like the WhatId or WhoId on task) for instance a Case can belong to a queue (Group) and so Owner.Email would be invalid. Task can also belong to a Queue (Group). If you look in the ...


6

the UserLogin SObject has an IsFrozen field, you can set this to true (from apex, api etc) to freeze a user. You can query this field from SOQL to determine who is frozen (and also who has a password lockout in effect), I haven't looked but i'd think you can do a regular report against this object as well.


6

You need to surround the expression with {! } to let Visualforce know to evaluate the expression and output the text into the page. Then, because you want the output to be a valid JavaScript string, quotes are also needed. (Without the quotes JavaScript assumes the name is an existing variable.) So altogether: alert('{!JSENCODE($User.FirstName)}'); Use ...


6

Salesforce.com Master Subscription Agreement 4.4 Usage Restrictions. You will not (a) make any Service or Content available to, or use any Service or Content for the benefit of, anyone other than You or Users, (b) sell, resell, license, sublicense, distribute, rent or lease any Service or Content, or include any Service or Content in a service bureau or ...


6

Yes you can do this. There are 3 steps to this: Prevent emails from going out. This can be done by going to Setup -> Administer -> Email Administration -> Deliverability and setting the 'Access Level' dropdown to 'No access'. Don't forget to Save. Update the email addresses of the users. This can be done by going to the User detail screen and ...


6

Explanation Take a look at sObjects That Cannot Be Used Together in DML Operations. It is not your call to UserInfo.getUserRoleId() that is causing the error. You get the error because you are setting the UserRoleId field to a non-null value. Based on the below, you could in theory write a class that can insert a User with a UserRoleId if you set the API ...


6

You have to use a Visualforce page to display the pic. Here is an example showing the profile pic on an employee record (custom object). <apex:page standardController="Employee__c"> <br /> <apex:image value="{!Employee__c.user__r.FullPhotoUrl}"/> </apex:page>


6

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 GroupMember where UserOrGroupId = 'userid' and Group.Type = 'Queue' Note: If the user is not added to the Queue directly this query won't work. Ex: If you add ...


6

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 as null. The obvious conclusion is that your DataFactory.createUser method is setting the UserRoleId to some other value. If you must specify this field for ...


6

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 solution here https://developer.salesforce.com/forums/?id=906F000000091B5IAI - but as it is so unreadable, not easily found by searching and buried in the last ...


6

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 license to avoid this .


6

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 are meant to extend the behaviour 2.Second case its obvious . If you want to restrict the behaviour for a user ,then disable at profile and do not assign ...


6

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 as you have mentioned: Variable does not exist: User.class Solution: Delete or rename User custom class and try again. Better Solution mentioned by ...


6

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 found one of them. As a matter of practicality, you don't need an "if" statement here, since your intent is to return true/false. You can also optimize this ...


5

Nope. You could add an external Id on the user record and then upsert if you're trying to load records. Or perhaps add a custom setting to store their Ids access multiple environments if you need to access that data through Apex.


5

I wasn't able to find a way to do this from regular Apex, but it is possible using the SOAP API. I've blogged a Visualforce solution that uses the Ajax toolkit to retrieve the frozen status of the users and provide buttons to freeze/unfreeze each user: http://bobbuzz.me.uk/185q7Yg


5

It appears under My Settings > Email > My Email Settings > Email Signature:


5

The Login as User feature is turned on by default in Sandboxes but you need to contact SalesForce to get it turned on in other orgs. To enable this login access policy: Step 1. Contact salesforce.com support to have this feature enabled in your organization first. You can’t complete the remaining steps until salesforce.com support enables the ...


5

Partner Community profile has permission "Delegated External User Administrator" and they can create disable community users. However, You cannot disable one community user by login other customer community user because Community profile does not provide "Manage User" or "Delegated External User Administrator" permission on profile. You can check this ...


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