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

Lightning Component Superbadge - Issue with Step 3
Challenge Not yet complete... here's what's wrong:
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.
getting this error
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.
getting this error
I'm getting same error with same code. Were u able to find any resolution? Can you help me out, please?
Anyone able to figure out what should be doing while encountering the error.
I am also still stuck at Step3, I am getting below error:
Challenge Not yet complete... here's what's wrong:
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.
Please, someone, tell what I should do.
Thanks - Naresh
I'm struck at Step3, below is the following error:
Challenge Not yet complete... here's what's wrong:
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.
BoatSearchResults
public with sharing class BoatSearchResults {
@AuraEnabled
public static List<Boat__c> getBoats(String boatTypeId) {
List<Boat__c> boats = new List<Boat__c>();
if (String.isEmpty(boatTypeId)) {
boats = [select Id,Name,Picture__c,Contact__r.name from Boat__c];
} else{
boats = [select Id,Name,Picture__c,Contact__r.name from Boat__c where BoatType__c = :boatTypeId ];
}
return boats;
}
}
Can someone help me out please ?
when you click on button Check Challange if you see in debug logs one log will get generated for your challenge and you will get AssertionException like System.AssertException: Assertion Failed: Boats found due to no data found.
So for this, you have to first run one method in Anonymous block which will create data for you in your org and then try again to check challenge. see below.
Mark this as Best Answer if your issues get resloved with this...!
String queryTemplate = 'SELECT Name,Id, Contact__c, Picture__c FROM Boat__c {0} {1}';
List<String> whereClauses = new List<String>();
if(String.isNotBlank(boatTypeId)){
whereClauses.add('BoatType__c =:boatTypeId');
}
return Database.query(
String.format(queryTemplate, new List<String> { whereClauses.size() > 0 ? 'WHERE' : '', String.join(whereClauses, ' OR ') }));
}
I'm struck at Step3, below is the following error:
Challenge Not yet complete... here's what's wrong:
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.
BoatSearchResults.apxc
public with sharing class BoatSearchResults {
@AuraEnabled
public static List <Boat__c> getBoats(String boatTypeId) {
if(boatTypeId != '') {
return [SELECT id, BoatType__c, picture__c, name,contact__r.Name FROM Boat__c WHERE BoatType__c =:boatTypeId];
} else {
return [SELECT id, BoatType__c, picture__c, name,contact__r.Name FROM Boat__c];
}
}
}
Can someone help me out ??
Please write the code like these
@AuraEnabled(cacheable=true) public static List<Boat__c> getBoats(String boatTypeId) {..}
@AuraEnabled(cacheable=true) public static List<Boat__c> getSimilarBoats(Id boatId, String similarBy) {..}
@AuraEnabled(cacheable=true) public static List<BoatType__c> getBoatTypes() {..}
@AuraEnabled(cacheable=false) public static List<BoatReview__c> getAllReviews(Id boatId) {..}
@AuraEnabled(cacheable=true) public static String getBoatsByLocation(Decimal latitude, Decimal longitude, String boatTypeId) {..}
@AuraEnabled(cacheable=true) public static String updateBoatList(Object data){..}
if it worked, choose the Best Answer.
Thanks,
Subhadeep