[SalesforceDeveloperCertification]認定 Platform デベロッパー資格の更新 (Winter ’25)

public class MyIterable implements Iterable<String> {
    private List<String> strings {get; set;}

    public MyIterable(List<String> strings) {
        this.strings = strings;
    }

    public Iterator<String> iterator() {
       return this.strings.iterator();
    }
}

@IsTest
private class MyIterableTest {
    
    @IsTest static void testIterableForLoop() {
        
            List<String> strings = new List<String>{'Hello','World'};
                
            MyIterable mi = new MyIterable(strings);

            Test.startTest();
            
            for (String str : mi) {
                System.debug(str);
            }

            Test.stopTest();
    }
}

[SalesforceDeveloperCertification]platform-developer-i-certification-maintenance-winter-24

platform-developer-i-certification-maintenance-winter-24

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) {
    //do not modify any code above this line
    //implement the logic that will use bindVars to retrieve the contact's ID
    String queryString =
        'SELECT ID FROM Contact WHERE lastName = :lastName AND title = :title LIMIT 1';
        List<Contact> Contacts = Database.queryWithBinds(
            queryString,
            bindVars,
            AccessLevel.USER_MODE
        );
      return Contacts[0].Id;
    }
    
}