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
Bosede Omolayo 16Bosede Omolayo 16 

Conference Management App - Create a Lightning Component with Server-Side Apex Controller

 Conference Management App - Create a Lightning Component with Server-Side Apex Controller:

Step 5: Add Component to the Speaker Record Page
Click App Default and then Assign as App Default.
Select the Conference app, then click Next and then Save.
Question: Does anyone know why Conference Management App is not listed for selection?

User-added image
I am also getting this error when I verify the hands on challenge:Note all APEX codes saved without errors. and all other steps worked.
Step not yet complete... here's what's wrong:
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

Thanks in advance for your help.
Best Answer chosen by Bosede Omolayo 16
SandhyaSandhya (Salesforce Developers) 
Hi,

Make sure that you are using brand new trailhead playground for thid challenge as there may be some pre existing configuration that is preventing to check challenge.

Best Regards,
Sandhya

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

Make sure that you are using brand new trailhead playground for thid challenge as there may be some pre existing configuration that is preventing to check challenge.

Best Regards,
Sandhya
This was selected as the best answer
Bosede Omolayo 16Bosede Omolayo 16
Using a new Trailhead Playground solved the error. Thank you
Joseph Bunda 6Joseph Bunda 6
You don't need to create a whole new org just for this challenge. Besides, who wants to start all over when they're seven steps in?

If you take a look at the logs, when you run the checker you can clearly see that it isn't able to find the ContentDocumentLink (which is the link between your Speaker__c record and a picture you should have uploaded earlier on). In looking at what the checker is doing, it's querying existing info from your org instead of trying to create it's own to test against. Tsk tsk.

Anyhow, the easier solution to this is to ensure that it can find the ContentDocumentLink record. You should already have one just by working through the challenges so far. So take this line of the AttachmentController apex class:
ContentDocumentLink docLink = [ SELECT ContentDocumentId
                               FROM ContentDocumentLink
                               WHERE LinkedEntityId = :recId order by Id desc Limit 1];

And change it to this:
ContentDocumentLink docLink;
try {
     docLink = [ SELECT ContentDocumentId
                        FROM ContentDocumentLink
                        WHERE LinkedEntityId = :recId order by Id desc Limit 1];
}
catch (Exception ex) {
     docLink = new ContentDocumentLink(ContentDocumentId='<Your 18-character record id here>');
}

The reason this works is that the challenge checker, for whatever reason, is able to query to find your Speaker__c records, but cannot query your ContentDocumentLink records. So if you change this particular query to return a "default" record when it fails for the challenge checker, you'll still come up with a valid record id that satisfies the challenge checker.
Ricki Marking-CamutoRicki Marking-Camuto
I tried Joseph's solution, and am still getting the same error message.  I grabbed the speaker record ID; was I supposed to grab something different?  I really would not like to have to start over from the beginning when I know it is a problem with the challenge checker, not my work.
Spencer MunceySpencer Muncey
Hey! While Sandhya's answer may be technically correct, Joseph's answer actually saves a lot of headache and heartache...I wasn't about to lose all my work up to this point.

Ricki, the '<Your 18-character record id here>'  refers to the record id of the profile picture. So step 6 of this trailhead wants you to test the application, so upload a profile picture of a speaker.

Then, using the console developer, run this query:
SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :recId order by Id desc Limit 1
You will noticed that this is the query to assign values to the docLink object created in the APEX code. The bind veriable :recId refers to the speaker record ID accessible from the SFDC URL. The ContentDocumentId from this query is what goes in line 8 of Joseph's screenshot
Jason Johnson 10Jason Johnson 10
I had made a new Trailhead Playground and recreated everything necessary to pass this one module; however, I tested the solution suggested by Joseph Bunda 6 and Spencer Muncey in the old Playground. This definately fixed the issue. Thanks so much for taking the time to explain what had gone wrong.
Esau SanchezEsau Sanchez
Hello everyone,
All you have to do to pass the challenge is add a picture to all your speakers (or at least the first one that the controller finds).

As I was reviewing my log, I noticed that the first speaker found by the query was not the one I had a picture for. I then uploaded a picture for that speaker and then passed the challenge without having to change any of the code as suggested previously.

I realize the code needs to be adjusted to prevent the error - the real error of finding a speaker without a picture, but if you just want to pass the challenge, just add pictures :)
Ratul KislayaRatul Kislaya
Thanks to @Joseph for guidance on this. The error is likely to happen in other queries as well. The guidance Joseph provided was good enough for me as a newbie to resolve this. So I'm pasting my class here:

Notice that I added an additional try-catch block to prevent further exceptions. While this solution is very hacky and I wouldn't recommend "learning" this approach for the applications you develop, this is solely in the interest of moving ahead in the trailhead. There's an opportunity to improvise this error in a more graceful way, I might revisit this later if I remember this in a more free time. 
public class AttachmentController {
	@AuraEnabled
    public static void updatePicturePath(String recId){
        //In Lightning Experience, Attachments are stored in ContentDocuments
        ContentDocumentLink docLink;
		try {
			docLink = [ SELECT ContentDocumentId
                        FROM ContentDocumentLink
                        WHERE LinkedEntityId = :recId order by Id desc Limit 1];
		} catch (Exception ex) {
			docLink = new ContentDocumentLink(ContentDocumentId='<insert your own 18-char ID>');
		}
        Speaker__c speaker = [SELECT Id FROM Speaker__c WHERE Id = :recId];
        String verId;
        try {
	        //ContentVersion Id uniquely identifies the attachment
			ContentVersion ver = [SELECT Id FROM ContentVersion Where ContentDocumentId = :docLink.ContentDocumentId ];
 			verId = ver.Id;
        } catch (Exception e2) {
            verId = '<same content ID as before>';
        }
        //Update the Picture_Path field with the url of the image    
        speaker.Picture_Path__c = '/sfc/servlet.shepherd/version/download/'+ verId;
        upsert speaker;
    }
}

 
J DeveloperJ Developer
@Esau Sanchez Thanks for the guidance.  Uploading a picture to every speaker record worked.  I tried a shortcut of copying a single picture path into all the records but this didn't work.
TSF DevTSF Dev
@J Developer I was just stuck at the check, your advice on updating all speakers with a picture solved the problem.
Ankit Maini.Ankit Maini.
I created 5 speakers initially and add profile pic and later deleted 4, it solved my prob,
ApuroopApuroop
Make sure that you can see the pictures on your Speaker Detail page in the Picture field. If the thumbnail is broken, you'll get an error. I created a few test speakers before but most of them had broken thumbnails. I delete the broken ones and kept the ones which are actually displaying the pics. This means that it can query only when you can see the pic. 
Salman Khan 180Salman Khan 180
you also can try this smm panel this is the best smm panel all over the world. https://newsmmpanel.com
Irina Aristova 10Irina Aristova 10
I added pictures to all speakers as per @Esau Sanchez. It worked!
MimicryBoyMimicryBoy
The same issue I was facing ...even if We upload the imagr wait for the toast message : Image/Record Saved Successfully.
Devian Studio 2Devian Studio 2
nice post, thanks for sharing!
Tubemate apk (https://devianstudio.net/)