PermissionCheckController Salesforce


public with sharing class PermissionCheckController {
    @AuraEnabled(cacheable=true)
    public static Boolean hasEditPermission(String permissionSetName) {
        // Get the User ID
        Id userId = UserInfo.getUserId();
        
        // Query the PermissionSetAssignment object
        PermissionSetAssignment psa = [
            SELECT Id 
            FROM PermissionSetAssignment 
            WHERE AssigneeId = :userId 
            AND PermissionSet.Name = :permissionSetName 
            LIMIT 1
        ];
        
        return psa != null;
    }
}

PermissionCheckController Salesforce PermissionCheckController Salesforce Reviewed by dasfrogpractice on 07:09 Rating: 5

No comments:

Theme images by mariusFM77. Powered by Blogger.
Youtube Channel Image
Dasfrog Subscribe To watch more Salesforce Training
Subscribe