I'm trying to check the User assigned Custom Permission from a Managed Package. The Custom Permission and the Permission Set are not part of the package, but in the subscribers Org.
Currently I'm trying to use the FeatureManagement.checkPermission()
, but seems that the package can't access to the Custom Permission record.
The call inside the package returns False
, when instead made from out of package (execute anonymous) the return value is True
.
To be clearer, an example of code I'm running:
//execute anonymous
System.debug(NS.MyClass.customPermissionMethod('myCustomPermission')); //return false
System.debug(FeatureManagement.checkPermission('myCustomPermission')); //return true
//Managed Package Class
global class MyClass {
global static boolean customPermissionMethod(value) {
return FeatureManagement.checkPermission(value);
}
}
I have not found anything on the documentation that spoke of this specific case, has it ever happened to you?