Created
April 3, 2020 01:40
-
-
Save surajp/36cd5582ad27bc50bbf665a12a09964c to your computer and use it in GitHub Desktop.
Check Feature in lwc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'})); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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