Platform Developer I Certification Maintenance (Winter '24) - Question Answerer
Module - 1 Ans
Module 2
1 ) Create an apex class with name
2) add this code
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) {
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()){
Id ids = contacts[0].Id;
return ids;
}
else{
return null;
}
}
}
3 ) Save the file
4) Check the Challanges
0 Comments