Lightning Web Components – Fix Undefined Permission Sets

lightning-web-componentspermission-sets

I'm currently trying to check whether or not the user has a permission set within the LWC and it's constantly returning undefined. I've confirmed the API Name and tried with and without the prefix. So far the only way I've got a work around is to create an Apex function that checks the PermissionSetAssignment.

This is the format I've tried used

import hasPermissionBulkUser from '@salesforce/userPermission/Bulk_Positions_User';

Which gives me undefined, I also tried with other PermissionSets and also a few customPermissions and all of them give the same result. Is there some setting I need to flip inside the scratch org to allow LWC to be able to access these?

Here's the format I used for the custom permissions

import hasPermission from '@salesforce/customPermission/Bulk_Positions_Access';

Best Answer

You have to assign the custom permission to the permission set, and assign the permission set to the user. The last one you tried should work.

import hasPermission from '@salesforce/customPermission/Bulk_Positions_Access';
Related Topic