【问题标题】:DocuSign API Template vs. no Template email responseDocuSign API 模板与无模板电子邮件响应
【发布时间】:2020-09-29 01:28:37
【问题描述】:

我正在开发一个在 iframe 中使用 DocuSign 签名的应用程序,该应用程序位于专有网络应用程序中。签名者可以在同一个网络应用程序中访问嵌入式 iframe 签名视图。

它是在没有考虑模板的情况下开发的。我已经通过构建包含 templateKey 和相应 TemplateRoles 的信封定义来实现模板的使用。非模板信封和模板信封调用相同的“CreateEnvelope”函数,但参数不同。设置页面加载已选择模板、定义角色和设置字段。单击“发送”按钮时会出现问题。

没有模板,就不会向签名者发送电子邮件。它允许签名者在我正在使用的专有应用程序中以嵌入式形式这样做。这是用于创建没有模板的信封的函数:

public EnvelopeSummary CreateEnvelope(string filePath, string username = null, string emailSubject = null, string brandID = null,List<Models.Recipient> recipients = null)
{
    EnvelopeDefinition envelopeDef = new EnvelopeDefinition
    {
        Status = "created",
        EmailSubject = emailSubject,
        BrandId = brandID
    };

    if (recipients != null)
    {
        List<Signer> signers = recipients.Select(x => new Signer() { Email = x.Email, Name = x.UserName, ClientUserId = x.RecipientID > 50 ? x.RecipientID.ToString() : null, RecipientId = x.RouteOrder.ToString(), RoutingOrder = x.RouteOrder.ToString() }).ToList();
        envelopeDef.Recipients = new Recipients() { Signers = signers };
    }

    return Factory.GetEnvelopesApi(DocuSignConfig).CreateEnvelope(accountId: Helpers.SettingsHelper.AccountID, envelopeDefinition: envelopeDef, options: null);
}

应用模板后,在工作流通过 SenderView 的返回 URL 返回到专有应用程序之前,签名者会收到一封外部签名的电子邮件。以下是使用模板创建信封的代码:

public EnvelopeSummary CreateTemplateEnvelope(string filePath,
                                                      List<DataModels.GetRole> roles = null,
                                                      DataModels.GetTemplate template = null,
                                                      string username = null,
                                                      string emailSubject = null,
                                                      string brandID = null,
                                                      List<Models.Recipient> recipients = null)
        {
            EnvelopeDefinition envelopeDef = new EnvelopeDefinition
            {
                Status = "created",
                EmailSubject = emailSubject,
                BrandId = brandID,
                TemplateId = template.TemplateKey
            };

            if (roles != null && recipients != null)
            {
                List<Signer> signers = recipients.Select(x => new Signer() { Email = x.Email, Name = x.UserName, ClientUserId = x.RecipientID > 50 ? x.RecipientID.ToString() : null, RecipientId = x.RouteOrder.ToString(), RoutingOrder = x.RouteOrder.ToString() }).ToList();
                var templateRoles = new List<TemplateRole>();
                int counter = 0;


                foreach (Signer signr in signers)
                {
                    TemplateRole thisSigner = new TemplateRole();
                    thisSigner.Email = signers[counter].Email;
                    thisSigner.Name = signers[counter].Name;
                    thisSigner.RoleName = roles[counter].RoleName;
                    templateRoles.Add(thisSigner);
                    counter++;
                }


                envelopeDef.TemplateRoles = templateRoles;
            }

            return Factory.GetEnvelopesApi(DocuSignConfig).CreateEnvelope(accountId: Helpers.SettingsHelper.AccountID, 
                                                                          envelopeDefinition: envelopeDef, 
                                                                          options: null);
        }

主要区别在于模板版本包含 templateKey,并且它使用 TemplateRoles 而不是 Recipients。模板代码比我想要的最终产品要粗略一些,但它是一项正在进行的工作,只是试图让它运行。有没有人了解如何或是否可以创建信封,然后保留使用嵌入式签名的能力?感谢您的帮助。

编辑:已解决

如答案的 cmets 中所述,通过根据收件人的值正确设置每个模板角色的 ClientUserId 解决了该问题。这允许使用模板角色签名者进行嵌入式签名。

【问题讨论】:

    标签: docusignapi


    【解决方案1】:

    要使用模板,您必须先从模板创建一个信封。 模板本身无法发送,因此您不能使用模板本身的嵌入式签名,只能使用模板创建的信封。 这是七种语言的code example。它显示了第一部分,要从结果信封中获取嵌入式签名,您可以使用 this code example

    这是给你的 C# 代码:

     string DoWork (string signerEmail, string signerName, string ccEmail,
        string ccName, string accessToken, string basePath,
        string accountId, string templateId)
    {
        // Data for this method
        // signerEmail 
        // signerName
        // ccEmail
        // ccName
        // accessToken
        // basePath
        // accountId
        // templateId
    
        var config = new Configuration(new ApiClient(basePath));
        config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
        EnvelopesApi envelopesApi = new EnvelopesApi(config);
        EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId);
        EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
        return result.EnvelopeId;
    }
    private RecipientViewRequest MakeRecipientViewRequest(string signerEmail, string signerName)
    {
        // Data for this method
        // signerEmail 
        // signerName
        // dsPingUrl -- class global
        // signerClientId -- class global
        // dsReturnUrl -- class global
    
        RecipientViewRequest viewRequest = new RecipientViewRequest();
        // Set the url where you want the recipient to go once they are done signing
        // should typically be a callback route somewhere in your app.
        // The query parameter is included as an example of how
        // to save/recover state information during the redirect to
        // the DocuSign signing ceremony. It's usually better to use
        // the session mechanism of your web framework. Query parameters
        // can be changed/spoofed very easily.
        viewRequest.ReturnUrl = dsReturnUrl + "?state=123";
    
        // How has your app authenticated the user? In addition to your app's
        // authentication, you can include authenticate steps from DocuSign.
        // Eg, SMS authentication
        viewRequest.AuthenticationMethod = "none";
    
        // Recipient information must match embedded recipient info
        // we used to create the envelope.
        viewRequest.Email = signerEmail;
        viewRequest.UserName = signerName;
        viewRequest.ClientUserId = signerClientId;
    
        // DocuSign recommends that you redirect to DocuSign for the
        // Signing Ceremony. There are multiple ways to save state.
        // To maintain your application's session, use the pingUrl
        // parameter. It causes the DocuSign Signing Ceremony web page
        // (not the DocuSign server) to send pings via AJAX to your
        // app,
        viewRequest.PingFrequency = "600"; // seconds
                                           // NOTE: The pings will only be sent if the pingUrl is an https address
        viewRequest.PingUrl = dsPingUrl; // optional setting
    
        r
    
    eturn viewRequest;
        }
    private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, 
                string ccEmail, string ccName, string templateId)
            {
                // Data for this method
                // signerEmail 
                // signerName
                // ccEmail
                // ccName
                // templateId
    
                EnvelopeDefinition env = new EnvelopeDefinition();
                env.TemplateId = templateId;
    
                TemplateRole signer1 = new TemplateRole();
                signer1.Email = signerEmail;
                signer1.Name =  signerName;
                signer1.RoleName = "signer";
                singer1.ClientUserId = "001";
    
                TemplateRole cc1 = new TemplateRole();
                cc1.Email = ccEmail;
                cc1.Name = ccName;
                cc1.RoleName = "cc";
    
                env.TemplateRoles = new List<TemplateRole> { signer1, cc1 };
                env.Status = "sent";
                return env;
            }
    

    【讨论】:

    • 感谢您的回复!我了解无法发送模板本身。我想对我的问题说的是,我创建了一个带有模板的信封,并且一旦发送它就不会流向现有的嵌入式签名代码。这个应用程序是由一位不再在我所在公司工作的开发人员构建的,因此我对嵌入式签名过程的工作原理没有完全了解。我将查看您提供的第二个示例,看看它是否可以阐明为什么带有模板的信封没有进入嵌入式签名步骤。
    • 您需要向收件人添加一个名为 clientUserId 的字段,以便该收件人用于嵌入式签名。
    • 所以在这里更改您的代码:foreach (Signer signr in signers) { TemplateRole thisSigner = new TemplateRole(); thisSigner.Email = 签名者[计数器].Email; thisSigner.Name = 签名者[计数器].Name; thisSigner.RoleName = 角色[计数器].RoleName; thisSigner.ClientUserId = "001"; // 使这个独一无二... templateRoles.Add(thisSigner);计数器++; }
    • 我会试试的。非常感谢!
    猜你喜欢
    • 2015-11-11
    • 2013-09-16
    • 2019-12-02
    • 1970-01-01
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    相关资源
    最近更新 更多