+ 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
RamakantRamakant
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

RamakantRamakant
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.