You need to sign in to do that
Don't have an account?

Execute SOQL and SOSL Queries challenge error
I am attempting to complete the Execute SOQL and SOSL Queries in the Developer Console Basics module and the challenge is creating logs that have nothing to do with the SOSL inline query that is requested. I have executed the following code in the Execute anonymous window and the challenge still does not show as completed.
So even with the above the challenge still returns with an error of:
List<List<sObject>> searchList = [FIND 'Mission Control' IN ALL FIELDS RETURNING Contact(FirstName, LastName, Phone, Email, Description)]; Contact[] searchContacts = (Contact[])searchList[0]; for (Contact c : searchContacts) { System.debug(c.LastName + ',' + c.FirstName); }
So even with the above the challenge still returns with an error of:
Challenge Not yet complete... here's what's wrong: Could not find the contact's name in the debug log. Be sure to run a query for your record, and to write your contact's name to the debug log using the System.debug() method.
All Answers
public class AccountsController {
@AuraEnabled
public static List<Account> getAccounts() {
return [SELECT Id, name, industry, Type, NumberOfEmployees, TickerSymbol, Phone
FROM Account ORDER BY createdDate ASC];
}
}
And below is my output in the log file generated from the above.
20:06:07:026 USER_DEBUG [7]|DEBUG|Found following Contacts Dent,Brian
My question is how to connect to a different or fresh developer organization.
- If I create a fresh login - how the badges will transfer to my original org.
- Connected to this new organization from my trail playground
- took the challenge again
result in log file:
11:18:18:060 USER_DEBUG [7]|DEBUG|Dent,Brian
Still can't pass the challenge.
RESULT:
Challenge Not yet complete... here's what's wrong:
Could not find the contact's name in the debug log. Be sure to run a query for your record, and to write your contact's name to the debug log using the System.debug() method.
Failed:
List<List<SObject>> contacts = [FIND 'Mission Control' IN ALL FIELDS RETURNING Contact(FirstName, LastName, Phone, Email, Title)];
System.debug(contact);
System.debug(contact.LastName + ',' + contact.FirstName);
Success:
List<List<SObject>> searchResults = [FIND 'Mission Control' in ALL FIELDS RETURNING Contact(Id, FirstName, LastName)];
//System.debug(contact);
System.debug(contact.LastName + ',' + contact.FirstName);;
Probable Conclusion: provide minimum what challenges are looking for. Anything extra may hurt.
be careful about the space after comma (,)
Challenge completed!
Try it with the Pat Penaherrera code, I had the same problem but with that code, it solve
I am having the same issues and i have logged into three different dev orgs. Still getting the same error. Would really like to get this badge. Thanks!
System.debug(c.LastName+', '+C.FirstName);
It's even easier than that, I had the same issue with creating contacts with the SOQL and there's no need to create a new dev org. You just need to locate a Trigger you created in a previous Trailhead module named 'ExampleTrigger' which sends an email after insert, just delete that trigger and you're ready to go.
Hope it helps!
RETURNING Contact(FirstName, LastName,
Phone, Email, Description)];
Contact[] searchContacts = (Contact[])searchList[0];
System.debug('Found the following contacts:');
for (Contact c : searchContacts) {
System.debug(c.LastName + ', ' + c.FirstName);
}
having the same issue but don't know-how in 3rd-time challenge passed. try the above code maybe that help , if not try in a fresh org
execute this snippet code first on your Execute Anonymous:
Contact thisContact = new Contact( Firstname='Brian', Lastname='Dent', Phone='(619)852-4569', Department='Mission Control', Title='Mission Specialist - Neptune', Email='briandent@trailhead.com');
insert thisContact;
Reopen Execute Anonymous Windows and execute this code:
List<List<sObject>> searchList = [FIND 'Mission Control' IN ALL FIELDS
RETURNING Contact(FirstName, LastName,
Phone, Email, Description)];
Contact[] searchContacts = (Contact[])searchList[0];
System.debug('Found the following contacts:');
for (Contact c : searchContacts) {
System.debug(c.LastName + ', ' + c.FirstName);
}
It should pass correctly.
(missing a space)