You need to sign in to do that
Don't have an account?
Sumi14
Error in - Build a Conference Management App : Create a Lightning Component with Server-Side Apex Controller
Getting as error in the challenge section of Build a Conference Management App - Create a Lightning Component with Server-Side Apex Controller . The error says "There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject".
This is what the server - side controller looks like:
public class AttachmentController {
@AuraEnabled
public static void updatePicturePath(String recId){
//In Lightning Experience, Attachments are stored in ContentDocuments
ContentDocumentLink docLink = [ SELECT ContentDocumentId
FROM ContentDocumentLink
WHERE LinkedEntityId = :recId order by Id desc Limit 1];
//ContentVersion Id uniquely identifies the attachment
ContentVersion ver = [SELECT Id FROM ContentVersion Where ContentDocumentId = :docLink.ContentDocumentId];
//Update the Picture_Path field with the url of the image
Speaker__c speaker = [SELECT Id FROM Speaker__c WHERE Id = :recId];
speaker.Picture_Path__c = '/sfc/servlet.shepherd/version/download/'+ ver.Id;
upsert speaker;
}
}
This is what the server - side controller looks like:
public class AttachmentController {
@AuraEnabled
public static void updatePicturePath(String recId){
//In Lightning Experience, Attachments are stored in ContentDocuments
ContentDocumentLink docLink = [ SELECT ContentDocumentId
FROM ContentDocumentLink
WHERE LinkedEntityId = :recId order by Id desc Limit 1];
//ContentVersion Id uniquely identifies the attachment
ContentVersion ver = [SELECT Id FROM ContentVersion Where ContentDocumentId = :docLink.ContentDocumentId];
//Update the Picture_Path field with the url of the image
Speaker__c speaker = [SELECT Id FROM Speaker__c WHERE Id = :recId];
speaker.Picture_Path__c = '/sfc/servlet.shepherd/version/download/'+ ver.Id;
upsert speaker;
}
}
I would suggest you try in new trailhead playground as the error says that there are some pre existing configuration that is preventing you.
Best Regards,
Sandhya
Adding images to ALL speakers worked for me.
Best Regards,
Sandhya