Salesforce Trailhead - Get Hands-on with Bind Variables in a SOQL Query

Поділитися
Вставка
  • Опубліковано 7 вер 2024
  • #salesforce #trailhead #codding
    Solution of Salesforce Trailhead - Get Hands-on with Bind Variables in a SOQL Query
    This trialhead is a part of Platform Developer I Certification Maintenance (Winter '24) Module.
    Watch the full solution of the Platform Developer I Certification Maintenance (Winter '24) Module - • Platform Developer I C...

КОМЕНТАРІ • 1

  • @YourCoddingBuddy
    @YourCoddingBuddy  8 місяців тому +5

    ********************* QueryContact Class *****************
    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 bindVars) {
    //do not modify any code above this line
    //implement the logic that will use bindVars to retrieve the contact's ID
    String query = 'SELECT ID FROM Contact WHERE lastName = :lastName AND title = :title LIMIT 1';
    List contacts = Database.queryWithBinds(query,bindVars,AccessLevel.User_Mode);

    if(!contacts.isEmpty()){
    return contacts[0].id;
    }
    else{
    return null;
    }
    }
    }