I am trying to fulfill the challenge to maintain my Platform Developer I certification. The challenge states under the method definition - "Do not modify any code above this line". Then I get an error that the method is not defined correctly. Based on the rules, I am not allowed to modify the method definition, as it is above the line quoted.
I saw an example in another Community question where the answer modified the definition of the method to use Id instead of List<Id>. Is this allowed?
@Jonathan Meltzer
Can you check and save the below code
If the issue persists, you can try on incognito mode or create new playground
public class QueryContact {
public static Id getContactID(String lastName, String title) {
try{
Contact myContact = Database.query(
'SELECT ID FROM Contact WHERE lastName =:lastName AND title =:title LIMIT 1'
);
return myContact.Id;
} catch (Exception ex){
return null;
}
}
public static Id getContactIDWithBinds(Map<String, Object>bindVars) {
// Updated method using bind variables
String query = 'SELECT Id FROM Contact WHERE lastName = :lastName AND Title =:title LIMIT 1';
List<Contact> contacts = Database.queryWithBinds(query,bindVars,AccessLevel.USER_MODE);
if (contacts != null && !contacts.isEmpty()) {
return contacts[0].Id;
} else {
return null;
}
}
}
please refer the similar thread: