SHARE
TWEET

Untitled

a guest Aug 17th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static string FormatFieldsForQuery(string objectName,string prefix){
  2.     if(string.isNotBlank(prefix)){
  3.         if(prefix.endsWith('__c'))
  4.             prefix=prefix.replace('__c','__r.');  
  5.         if(!prefix.endsWith('.'))
  6.             prefix+='.';
  7.     }
  8.     string fields = '';
  9.     sObjectType objectType=Schema.getGlobalDescribe().get(objectName);
  10.     if(objectType==null)
  11.         return fields;
  12.     for(string f :objectType.getDescribe().fields.getMap().keySet())
  13.         fields+=prefix+f+',';
  14.     return fields.removeEnd(',');  
  15. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top