Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string FormatFieldsForQuery(string objectName,string prefix){
- if(string.isNotBlank(prefix)){
- if(prefix.endsWith('__c'))
- prefix=prefix.replace('__c','__r.');
- if(!prefix.endsWith('.'))
- prefix+='.';
- }
- string fields = '';
- sObjectType objectType=Schema.getGlobalDescribe().get(objectName);
- if(objectType==null)
- return fields;
- for(string f :objectType.getDescribe().fields.getMap().keySet())
- fields+=prefix+f+',';
- return fields.removeEnd(',');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement