我创建了一个具有附件上传功能的visualforce页面。 附件将上传到自定义对象发票下。
现在,内部用户可以使用选项卡访问此页面,也可以在salesforce站点上公开访问此页面。
上传功能在salesforce实例中非常有效,但在网站上传附件时,附件变量未设置。
这里是片段:(不完整的代码)
<apex:outputPanel id="AddAttachmentinner">
<div class="slds-form-element">
<label class="slds-form-element__label">Select Relevant Attachment:</label>
<br/>
<apex:inputFile title="Choose File" value="{!filebody}" filename="{!filename}" />
<br/> Please select only pdf, xls, doc, jpg, tiff, png type of files
</div>
</apex:outputPanel>
public pagereference SubmitInvoice(){
public String filename {
get;
set;
}
public Blob filebody {
get;
set;
}
public Attachment attachment {
get;
set;
}
if (filebody != null && filename != null && filename != '') {
attachment.Name = filename;
attachment.Body = filebody;
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = newInvoice.Id; // the record the file is attached to
attachment.IsPrivate = false;
upsert attachment;
}
}
我在这里错过了什么吗?