Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //prints a SOQL query for all fields of an object, paste into the SOQL editor in webstorm to get a feeling for an object type in the database
- String type='spo4__SalesProcess__c';
- Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
- Schema.SObjectType leadSchema = schemaMap.get(type);
- Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
- List<String> fieldList = new List<String>();
- for (String fieldName: fieldMap.keySet()) {
- fieldList.add(fieldName);
- }
- String SOQLString = '\n\nSELECT ' + string.join(fieldList,', ');
- SOQLString += ' FROM ' + type + ' LIMIT 10\n';
- System.debug(SOQLString);
- //prints "##Field API Name: {API Name} => {Label Name}" for all fields on an object
- String type='OpportunityStage';
- Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
- Schema.SObjectType leadSchema = schemaMap.get(type);
- Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
- for (String fieldName: fieldMap.keySet()) {
- System.debug('##Field API Name: ' + fieldName + ' => ' + fieldMap.get(fieldName).getDescribe().getLabel());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement