function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Charmaine van der MerweCharmaine van der Merwe 

Trailhead: Surface data from IBM Watson: Unexpected token error

I copied this code from the Trailhead page to create an Apex class:

User-added image

I get this error:
Error: Compile Error: Unexpected token 'list'. at line 2 column 15
Please help?
Best Answer chosen by Charmaine van der Merwe
RKSalesforceRKSalesforce
Hi Charmaine,
code provided om Trailhead is for Method. We need to add this code inside Class like below:
public class IBMWatsonDiscovery_Controller{
	@AuraEnabled
	public static List<Watson_Discovery__x> getSearchResults(String name) {
		List<List<SObject>> allResults = [FIND :name IN Name Fields RETURNING Watson_Discovery__x(User__c,Twitter__c) LIMIT 25];
		List<Watson_Discovery__x> results = allResults[0];
		return results;
	}
}

Hope this will work. Mark answer if helped.

Regards,
Ramakant​
 

All Answers

RKSalesforceRKSalesforce
Hi Charmaine,
code provided om Trailhead is for Method. We need to add this code inside Class like below:
public class IBMWatsonDiscovery_Controller{
	@AuraEnabled
	public static List<Watson_Discovery__x> getSearchResults(String name) {
		List<List<SObject>> allResults = [FIND :name IN Name Fields RETURNING Watson_Discovery__x(User__c,Twitter__c) LIMIT 25];
		List<Watson_Discovery__x> results = allResults[0];
		return results;
	}
}

Hope this will work. Mark answer if helped.

Regards,
Ramakant​
 
This was selected as the best answer
Charmaine van der MerweCharmaine van der Merwe
Thank you.  It's so obvious now that you pointed it out.  Thanks very much.