1

How to check whether logged user having 'convert lead' permission on lead object or not?

1

Not sure of the context of getting this but you can find the permission in the permissionset object with the query below given the current user id.

SELECT permissionsConvertLeads FROM PermissionSet WHERE profileid = 'userprofileid'

  • Just use. Id profileId=userinfo.getProfileId(); – datmannz Dec 12 '14 at 7:51
  • SELECT permissionsConvertLeads FROM PermissionSet WHERE PermissionSet.Profile.Id = 'userprofileid' like this it is Working.Thanks – Shilpa Dec 18 '14 at 5:27
0

I needed to implement something this week that checks this permission, but I'm not sure the accepted answer solves all use cases.

If the user was given the Lead Convert permission through a permission set and not via the profile, I am fairly certain that the PermissionSet record for their profile will have this permission as false but the PermissionSet record for their permission set will have this permission as true.

I implemented something like:

Boolean CanConvertLeads = false;

List<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = :UserInfo.getUserId()];
Set<Id> permissionSetIds = new Set<Id>();
for (PermissionSetAssignment assignment : permissionSetAssignments) permissionSetIds.add(assignment.PermissionSetId);

if (permissionSetIds.size() > 0) {
    List<PermissionSet> permissionSets = [SELECT PermissionsConvertLeads FROM PermissionSet WHERE Id IN :permissionSetIds];
    for (PermissionSet permissionSet : permissionSets) {
        if (permissionSet.PermissionsConvertLeads) CanConvertLeads = true;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.