You need to sign in to do that
Don't have an account?
Sandeep Yadav
Write an Inline SOSL Search to Return Database Values
On execution this in my Anonymous window --
List<List<sObject>> searchList = [FINd 'Mission Control' in ALL Field
RETURNING Contact(FirstName,LastName,Email,Phone,Department)];
Contact[] searchContacts = (Contact[])searchList[0];
System.debug(searchContacts[0].LastName + ' ,' + searchContacts[0].FirstName);
a PopBox says that-
Unexpected Token at Line 1
List<List<sObject>> searchList = [FINd 'Mission Control' in ALL Field
RETURNING Contact(FirstName,LastName,Email,Phone,Department)];
Contact[] searchContacts = (Contact[])searchList[0];
System.debug(searchContacts[0].LastName + ' ,' + searchContacts[0].FirstName);
a PopBox says that-
Unexpected Token at Line 1
You are not putting the system.debug correctly for the challenge.
Please try with below code. This will work fine
Reason :
You have put two extra spaces in comma . Change below to
to
Your debug line is causing the challenge not to be completed.
Happy TrailBlazing :)
All Answers
Your SOSL has typo error(Field) . It will be 'Fields'. Change this below SOSL to
List<List<sObject>> searchList = [FINd 'Mission Control' in ALL Fields
RETURNING Contact(FirstName,LastName,Email,Phone,Department)];
and you are good to go :)
But i still get an error--
"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."
In my debug log i can see contact's first and last name
Are you doing this trailhead module?
https://trailhead.salesforce.com/en/modules/apex_database/units/apex_database_sosl
If yes , then may be you are not fetching the lead. Please try using above code and let us know.
It should be ', '
Change
to
Hope this helps :)
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.
here what I did after your suggestion--
List<List<sObject>> searchList = [FINd 'Mission Control' in ALL Fields
RETURNING Contact(FirstName,LastName,Email,Phone,Department)];
Contact[] searchContacts = (Contact[])searchList[0];
System.debug(searchContacts[0].LastName + ' , ' + searchContacts[0].FirstName);
You are not putting the system.debug correctly for the challenge.
Please try with below code. This will work fine
Reason :
You have put two extra spaces in comma . Change below to
to
Your debug line is causing the challenge not to be completed.
Happy TrailBlazing :)
Its very deeply observation