• Ramanujam Varadhan 4
  • NEWBIE
  • 69 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hello all,

I'm unable to complete the challenges for steps 3-5 in the "Apex Basics & Database" Trailhead module. I can't figure out what could be wrong with any of my classes. The message I get for all three is a variation on:

"Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results."

All of the classes are public. All of the methods are public and static. I've checked the return types and have successfully run them all with test data. I've tried re-entering the test data provided in the module to make sure it's accurate. No idea what I'm doing that makes this fail. (I'm not using a custom namespace.)

I'll paste my code below. Any tips would be greatly appreciated!

Thanks,
Mike

public class AccountHandler {
    public static ID insertNewAccount(String acctName) {
        Account newAcct = new Account(Name=acctName);
        try {
            insert newAcct;
        } catch (DMLException e) {
            System.debug('A DML exception has occurred: ' +
                         e.getMessage());
            return Null;
        }        
        return newAcct.Id;
    }
}

public class ContactSearch {
    public static List<Contact> searchForContact(
        String lastName, String postalCode) {
            List<Contact> contacts = new List<Contact>();
            contacts = [SELECT Name
                        FROM Contact
                        WHERE LastName = :lastName AND
                        MailingPostalCode = :postalCode ];           
            return contacts;
        }
}

public with sharing class ContactAndLeadSearch {
    public static List<List<SObject>> searchContactsAndLeads(String srch) {
        List<List<SObject>> results = [FIND :srch IN NAME FIELDS];
        }
}
Hello all,

I'm unable to complete the challenges for steps 3-5 in the "Apex Basics & Database" Trailhead module. I can't figure out what could be wrong with any of my classes. The message I get for all three is a variation on:

"Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results."

All of the classes are public. All of the methods are public and static. I've checked the return types and have successfully run them all with test data. I've tried re-entering the test data provided in the module to make sure it's accurate. No idea what I'm doing that makes this fail. (I'm not using a custom namespace.)

I'll paste my code below. Any tips would be greatly appreciated!

Thanks,
Mike

public class AccountHandler {
    public static ID insertNewAccount(String acctName) {
        Account newAcct = new Account(Name=acctName);
        try {
            insert newAcct;
        } catch (DMLException e) {
            System.debug('A DML exception has occurred: ' +
                         e.getMessage());
            return Null;
        }        
        return newAcct.Id;
    }
}

public class ContactSearch {
    public static List<Contact> searchForContact(
        String lastName, String postalCode) {
            List<Contact> contacts = new List<Contact>();
            contacts = [SELECT Name
                        FROM Contact
                        WHERE LastName = :lastName AND
                        MailingPostalCode = :postalCode ];           
            return contacts;
        }
}

public with sharing class ContactAndLeadSearch {
    public static List<List<SObject>> searchContactsAndLeads(String srch) {
        List<List<SObject>> results = [FIND :srch IN NAME FIELDS];
        }
}
The Challenge for this (https://developer.salesforce.com/en/trailhead/force_com_programmatic_beginner/visualforce_fundamentals/visualforce_variables_expressions)Trailhead unit asks us to create a VisualForce page named "myHelloWorldVF" that displays the first name of the logged-in user.

Here is the VF I am using:
<apex:page>
{!$User.FirstName}
</apex:page>
(note: I have also tried wrapping the binding inside tags like <div>, <p>, <apex:outputText>, etc with no luck. I also tried minimizing the rendered output by including sidebar="false" standardStylesheets="false" showHeader="false")

The error returned in Trailhead after clicking "Check Challenge" is:
"Challenge not yet complete... here's what's wrong: 
The Visualforce page did not fit the criteria. The first name of the loged in user was not output using dynamic global variables." 

I am not aware of a different global var within VF for getting User attributes.

Anyone have luck with getting this one to pass?
  • October 28, 2014
  • Like
  • 0