A developer needs to display all of the available fields for an object. In which two ways can the developer retrieve the available fields if the variable myObject represents the name of the object? (Choose two.)
A.
Use myObject.sObjectType.getDescribe().fieldSet() to return a set of fields.
B.
Use mySObject.myObject.fields.getMap() to return a map of fields.
C.
Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields.
D.
Use getGlobalDescribe().get(myObject).getDescribe().fields.getMap() to return a map of fields.
You can test the three ways in developer console :
Map<String,Schema.SObjectField> m = Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap();
system.debug('Map 1 ' + m.Values());
Map<String,Schema.SObjectField> m2 = Schema.describeSObjects(new String[]{'Account'})[0].fields.getMap();
system.debug('Map 2 ' + m2.Values());
Map<String, Schema.SObjectField> m3 = Schema.SobjectType.account.fields.getMap();
system.debug('Map 3 ' + m3.Values());
Only C is actually correct here, but D is good if you add 'Schema.' before getGlobalDescribe()
three ways to get fields:
system.debug(Schema.getGlobalDescribe().get('Building__c').getDescribe().fields.getMap());
system.debug(Schema.describeSObjects(new String[]{'Building__c'})[0].fields.getMap());
system.debug(schema.SObjectType.Building__c.fields.getMap());
mySObject.Building__c.fields.getMap();
upvoted 3 times
...
This section is not available anymore. Please use the main Exam Page.CRT-450 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
noox
Highly Voted 2 years, 4 months agokhoce
Highly Voted 2 years agoNand072
Most Recent 8 months, 4 weeks agoNand072
8 months, 4 weeks agoOMsairam
2 years, 5 months agoDonAldos
2 years, 7 months agoam1
4 years ago