Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement