You need to sign in to do that
Don't have an account?
Salesforce Site - Cannot Upload Attachment
With Salesforce's latest release, it appears to have broken file upload by guest users. I thought it was resolved with this ISSUE (https://trailblazer.salesforce.com/issues_view?id=a1p3A000001YpGnQAK) but that doesn't seem to apply to my problem.
I have a Salesforce Site that hosts a visualforce page to allow guest users to update a custom object record and attach a file, via the [New] button on the Attachments related list. Now, however, that upload attempt sends the user to the Unauthorized page. So, I swapped the related list for an apex:inputFile component. The mere existence of that component causes the Unauthorized page upon submission.
Here's a sample page:
<apex:page controller="customController" doctype="html-5.0" showheader="false" sidebar="false"> <apex:outputpanel id="responsePnl"> <apex:form id="responseFrm"> <apex:pageblock id="responseBlock" mode="edit"> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!submitResponse}" value="Submit" rerender="responsePnl"> </apex:commandButton> </apex:pageBlockButtons> <apex:inputFile value="{!att.body}" filename="{!att.name}"/> </apex:pageblock> </apex:form> </apex:outputpanel> </apex:page>and here's a sample controller:
public without sharing class customController{ public Attachment att { get; set; } public customController() { att = new Attachment(ParentId = 'a5p030000008Opb'); } public PageReference submitResponse() { if (att.Name != null) { insert att; } return null; } }
If the inputFile is commented out, there are no issues submitting.
I've checked Files > General Settings > "Allow site gue users to upload files"
The Site Guest Profile has Modify All permissions to the custom object.
Secure Guest User Record Access has been enabled and disabled.
Sharing Setting created to enable Read access to the parent object.
Is there something I overlooked with the new Guest permission enforcement?
Other notes:
inputFile causes failed submission everytime.
Attachment related list fails after going through the file upload wizard
Attachment relate list will allow successful update to the custom object if no file upload is attempted.
Salesforce Tier3 Support:
One thing to note is that in my quick test implementation, I forgot about the rule that you cannot have a rerender action combined with a visualforce input. VF developers will need to use apex:input file and handle the data encoding via code. The same may apply to any LWC implementations.
All Answers
Greetings!
The known bug was fixed in the Summer'20 release and the guest user should be able to upload the file successfully even after the "Secure Guest user Record Access" permission enabled.
I would suggest you to narrow down the code just to upload the file as the guest user and see,if the issue is persists.If yes,then I would suggest you to reach out to the salesforce.com support to investigate further on this.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Here's the controller. The accompanying page is a single commandButton that calls submitResponse();
Salesforce Tier3 Support:
One thing to note is that in my quick test implementation, I forgot about the rule that you cannot have a rerender action combined with a visualforce input. VF developers will need to use apex:input file and handle the data encoding via code. The same may apply to any LWC implementations.