function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
inbox outbox 7inbox outbox 7 

I would like to know the result of getMap() in the below code?

  Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Prasadam__c.fields.getMap();


'SObjectField' would be fieldName.
What about the string here? 
Kindly help me understand, this code. Thank you. Code is good, I am just trying to understand here. 

For your reference below is the rest of the code. 
@isTest

private static void testIsAccessible() {
    Map<String, User> users = getUsers();
    List<Contact> wsContacts;
    System.runAs(users.get('William Shattner')) {
        wsContacts = [SELECT Name, Phone, MailingStreet FROM Contact];
        Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Contact.fields.getMap();
        Map<String, Boolean> fieldToAccessibility = new Map<String, Boolean>();
        for (Contact contact : wsContacts) {
            Set<String> populatedFields = contact.getPopulatedFieldsAsMap().keySet();
            for (String fieldName : populatedFields) {
                Boolean isAccessible = fieldToAccessibility.get(fieldName);
                if (isAccessible == null) {
                    isAccessible = fieldMap.get(fieldName).getDescribe().isAccessible();                  fieldToAccessibility.put(fieldName,isAccessible);
                }
                if (!isAccessible) {
                    contact.put(fieldName, null);
                }
            }
        }
     }
     System.debug(wsContacts);

 
PriyaPriya (Salesforce Developers) 
Hi,

String also contains the fieldName.You can check by running it in anonymous window.
 
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Contact.fields.getMap();
system.debug('Map data',+fieldMap);

Hope this is helpful!!

Regards,
Ranjan