This is for the "Platform Developer Beginner -> Get Started with Salesforce Development -> Write Business Logic in Apex" module.
I have a fresh install of vscode as instructed by this module, but the syntax hightlighting isn't fully working, and when I go to deploy the (snippet provided by trailhead module) code it also gives compilation errors.
I'm thinking the vscode apex syntax extensions aren't working properly.
Does anyone know how to troubleshoot this?
VSCode is not my IDE of choice so I'm not an expert at finding the errors here.
I was getting the same error, the code is wrong, this should fix it:
public with sharing class HouseService {
@AuraEnabled(cacheable=true)
public static List<House__c> getRecords() {
try {
// Create a list of House records from a SOQL query
List<House__c> lstHouses = [
SELECT
Id,
Name,
Address__c,
State__c,
City__c,
Zip__c
FROM House__c
WITH SECURITY_ENFORCED
ORDER BY CreatedDate
LIMIT 10
];
return lstHouses;
}
// Code to handle exception
catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}