You need to sign in to do that
Don't have an account?
inbox outbox 7
The code which needs to be corrected is in bold letters.
I have trouble quering inside a map.
Thank you
I need help with updating the code to a MAP as opposed to a LIST.
@isTest private static void testIsAccessible() { Map<String, User> users = New Map<String, User>(); 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);
The code which needs to be corrected is in bold letters.
I have trouble quering inside a map.
Thank you
Can you please try below Hope this is helpful!
Regards,
Ranjan