SHARE
TWEET

Untitled

a guest Jul 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * @description  Method to get the dynamic sObject provided
  3. * @param fieldsToRetrieve - comma separated API names of the field you wish to return
  4. * @param objectToReturn - sObject to return
  5. * @param whereClause - filters on the WHERE clause
  6. * @return String - returns blank if there are no results
  7. */
  8. @AuraEnabled
  9. public static String retrieveSObject(String fieldsToRetrieve, String objectToReturn, String whereClause) {
  10.     String returnObj = '';
  11.     if (String.isNotBlank(fieldsToRetrieve) && String.isNotBlank(objectToReturn) &&  String.isNotBlank(whereClause)) {
  12.         String soqlQuery = 'SELECT ' + fieldsToRetrieve + ' FROM ' + objectToReturn + ' WHERE ' + whereClause;
  13.         List<sObject> sObjList = database.query(soqlQuery);
  14.  
  15.         System.debug('@@@@@@@@@@@@@@ sObjList ' + sObjList);
  16.         if (!sObjList.isEmpty()) {
  17.             returnObj = JSON.serialize(sObjList);
  18.         }
  19.     }
  20. return returnObj;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top