Getting error message "The 'Picture_Path__c' custom field in the Speaker object is null. Upload an image and try again." - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Shubham KashyapShubham Kashyap 

Getting error message "The 'Picture_Path__c' custom field in the Speaker object is null. Upload an image and try again."

Greetings All,

I was taking this Trailhead course Build a Conference Management App and got stuck in this part Create an Aura Component with a Server-Side Apex Controller. I created all the component/actionHandler/controller as per the instructions provided in the course even though I am getting this error.

See my created Items below:
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;
    }

ImageUploader.cmp controller
({
    handleUploadFinished: function (component, event) {
        // Get the list of uploaded files
        var uploadedFiles = event.getParam("files");
        //set action to call updatePicturePath method from Server-side controller
        var action = component.get("c.updatePicturePath");
        action.setParams({
            recId : component.get("v.recordId")
        });
        action.setCallback(this, function(a){
            if(a.getState() === "SUCCESS"){
                var resultToast = $A.get("e.force:showToast");
                resultToast.setParams({
                            "title": "Success!",
                            "message": uploadedFiles.length + "file uploaded successfully."
                        });
                resultToast.fire();;
            }
        });
        $A.enqueueAction(action);
    }
})

ImageUploader.cmp
<aura:component controller="AttachmentController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="String" />
    <lightning:fileUpload label="Attach Picture"
                name="fileUploader"
                multiple="true"
                accept=".pdf, .png, .jpg"
                recordId="{!v.recordId}"
                onuploadfinished="{!c.handleUploadFinished}" />
</aura:component>

Please suggest what am I doing wrong here.
Course Link -  https://trailhead.salesforce.com/content/learn/projects/salesforce_developer_workshop/creating_lc_with_apex_controller​​​​​​​ (https://trailhead.salesforce.com/content/learn/projects/salesforce_developer_workshop/creating_lc_with_apex_controller)

Thanks,
Shubham
Best Answer chosen by Jayson (salesforce.com) 
Dominika PalinkoDominika Palinko
I just resolved the issue by clearing my cache and uploading the images in an incognito window. I hope this helps!

All Answers

Priyanka DadhePriyanka Dadhe
Hi Shubham,

Did you add picture in your Speaker object record?

 
Shubham KashyapShubham Kashyap
Hi Priyanka,

Yes I did, but the issue is it is not getting uploaded. Also I see a icon already showing in the "Picture" field before uploading a file.

Attaching snapshots.
Before uploading the file

Uploading PDF file

Error Message

 
Harsh ParekhHarsh Parekh
Hi Everyone,

I am also getting the same error messgae of Shubham.
 have also witted the same code , i am also getting the done message after uploading but after that it is showing same as of shubham.
Please help us.
If onyone know how to corrct it.
Is there any iss   //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;ue with the Picture_Path__c?

Please let us know.
Nithisha KNithisha K
Encountering the same issue. 
Kapil ShahKapil Shah
Even i am encountering the same issue,any updates or solution till now?
Shay RavacchioliShay Ravacchioli
Experiencing the same issue! Would love to get this resolved so I can make progress on the project.
Seth MalwitzSeth Malwitz
Same issue for me as well.
Pradeep KondaPradeep Konda
same issue here
Dominika PalinkoDominika Palinko
I have the same issue.
Dominika PalinkoDominika Palinko
I just resolved the issue by clearing my cache and uploading the images in an incognito window. I hope this helps!
This was selected as the best answer
Naren MohananNaren Mohanan
Thanks. I followed your suggestion to clear the cahce and run in incognito Window and it worked.
Adrianne GeyerAdrianne Geyer
First, make sure in Step 1, the Formula Return Type is Text instead of None. After you upload the image, click Ctrl R to do a hard refresh. These 2 things worked for me without having to go incognito.
Stephen GuzmanStephen Guzman
not able to get working by any of the solutions listed above.