Skip to content

Instantly share code, notes, and snippets.

@surajp
Created April 3, 2020 01:40
Show Gist options
  • Save surajp/36cd5582ad27bc50bbf665a12a09964c to your computer and use it in GitHub Desktop.
Save surajp/36cd5582ad27bc50bbf665a12a09964c to your computer and use it in GitHub Desktop.
Check Feature in lwc
import checkCustomPermission from '@salesforce/apex/CheckFeatureController.checkFeature';
const checkFeature= async (featureName)=>{
try{
const result = await checkCustomPermission({featureName});
return result;
}catch(err){
console.error('Error in checking custom permissions '+err.message);
throw err;
}
}
export {checkFeature}
import {checkFeature} from 'c/checkCustomPermissionLwc';
checkFeature(HOLD_ORDERS_PERM)
.then(res=>{
this.holdReleaseOrders = res;
}).catch(err=>{
this.dispatchEvent(new ShowToastEvent({message:err.message,title:'Error',variant:'error'}));
})
public with sharing class CheckFeatureController {
@AuraEnabled
public static boolean checkFeature(String featureName){
return FeatureManagementCheckerFactory.getFeatureManagementChecker().checkPermission(featureName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment