Apex Method Signature
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
@AuraEnabled public static String methodName(String recordId, String objectName) { try { if(recordId!= null) { } return null; } catch (Exception e) { System.debug(e.getMessage() + ' -> ' + e.getStackTraceString()); throw new AuraHandledException(e.getMessage()); } } |
JSON Deserialize
1 2 3 |
List<PicklistWP> recordList = (List<PicklistWP>) JSON.deserialize(records, List<PicklistWP>.class); |
Get Picklist Values with wrapper
1 2 3 4 5 6 7 8 9 |
private static List<PicklistWP> getPicklistOptions(String objectName, String fieldName) { List<PicklistWP> options = new List<PicklistWP>(); for (Schema.PicklistEntry picklistVal : Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap().get(fieldName).getDescribe().getPicklistValues()) { options.add(new PicklistWP(picklistVal.getLabel(), picklistVal.getValue())); } return options; } |
1 2 3 4 5 6 7 8 9 10 |
public class PicklistWP { @AuraEnabled public String label; @AuraEnabled public String value; public PicklistWP(String label, String value) { this.label = label; this.value = value; } } |
Check if String is a valid sObject
1 2 3 4 5 6 7 |
Schema.SObjectType objectName = Schema.getGlobalDescribe().get(sObjectName); if(objectName == null) { throw new MyException('Object API Name is Not Valid'); } |