【问题标题】:Attachment not getting set on visualforce on salesforce sites附件未在 Salesforce 站点中的 visualforce 上设置
【发布时间】:2016-01-19 05:22:16
【问题描述】:

我创建了一个具有附件上传功能的 visualforce 页面。 附件在自定义对象发票下上传。

现在内部用户可以使用选项卡访问此页面,也可以在 Salesforce 网站上公开访问。

上传功能在 Salesforce 实例中完美运行,但在网站上上传附件时,附件变量未设置。

这里是sn-p:(不完整的代码)

<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;
    }

}

我错过了什么吗?

【问题讨论】:

  • 您确定为您的对象设置了适当的权限吗?站点用户作为 OwnerId 是否有效?您确定您的 newInvoice 记录具有 Id 值吗?你检查过开发者控制台的日志吗?只是抛出我会检查的想法。如果您在apex:page 下方添加apex:pageMessages 标签,您也可能会从服务器收到一些错误消息。
  • 嘿@Peter 感谢您回来。可以肯定的是,我在控制器的附件变量中插入了一个虚拟文件名和 blob 并且它起作用了。它只是在使用 inputfile 标签时没有设置附件。我在这里错过了什么吗?

标签: salesforce


【解决方案1】:

点击链接到此tutorial

干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多