You need to sign in to do that
Don't have an account?
inbox 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.
'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);
String also contains the fieldName.You can check by running it in anonymous window.
Hope this is helpful!!
Regards,
Ranjan