简体   繁体   English

使用Docusign API使用C#SDK将多个文档添加到信封

[英]Add multiple documents to envelope using c# sdk using Docusign API

I have a template in Docusign that I need to send to joe@acme.com 我在Docusign中有一个模板,需要发送至joe@acme.com

However Joe is responsible for managing 10 clients and instead of me sending Joe 10 separate envelopes for him to sign I want to send Joe 1 envelope with 10 documents and Joe needs to sign all 10 document in the envelope. 但是,Joe负责管理10个客户,而不是由我发送给Joe 10个单独的信封供他签名,我想发送带有10个文档的Joe 1个信封,而Joe需要在信封中签名所有10个文档。 The documents are identical except for the different data filled in the text field of the template 这些文档是相同的,只是模板文本字段中填充的数据不同

I am using the C# SDK provided by Docusign and I can send one document in an envelope using EnvelopeDefinition class and TemplateRole class but am lost as to how to create 10 documents in an envelope 我正在使用Docusign提供的C#SDK,并且可以使用EnvelopeDefinition类和TemplateRole类在信封中发送一个文档,但是对于如何在信封中创建10个文档却迷失了方向

The following recipe does it but it is in python and uses the REST API with which I am not sure how to translate to the C# SDK equivalent https://www.docusign.com/developer-center/recipes/send-multiple-docs 以下食谱可以做到这一点,但是它是在python中使用的,并且使用REST API,我不确定该REST API如何转换为等效于C#SDK的https://www.docusign.com/developer-center/recipes/send-multiple-docs

You can use compositeTemplates and reuse the same server template multiple times in the envelope. 您可以使用CompositeTemplates并在信封中多次重复使用同一服务器模板。 The below code uses the same server Template and repeats it 10 times in the envelope. 以下代码使用相同的服务器模板,并在信封中重复10次。 See full example here 在此处查看完整示例

public void CreateEnvelope()
{
  var envDef = new EnvelopeDefinition()
  {
      EmailSubject = "Envelope with multiple documents",
      Status = "sent",
      CompositeTemplates = new List<CompositeTemplate>()
  };

  for (int docNumber = 1; docNumber <= 10; docNumber++)
  {
      var compostiteTemplate = BuildCompositeTemplate(docNumber.ToString());
      envDef.CompositeTemplates.Add(compostiteTemplate);

  }

  EnvelopesApi envelopesApi = new EnvelopesApi();
  EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
  Console.WriteLine(envelopeSummary);
}

public CompositeTemplate BuildCompositeTemplate(string docNumber)
{
    string serverTemplateId = "";//Add your server template ID here
    return new CompositeTemplate()
    {
          ServerTemplates = new List<ServerTemplate>()
          {
              new ServerTemplate()
              {
                  TemplateId = serverTemplateId,
                  Sequence = docNumber
              }
          },
          InlineTemplates = new List<InlineTemplate>()
          {
              new InlineTemplate()
              {
                  Sequence = docNumber,
                  Recipients = new Recipients()
                  {
                      Signers = new List<Signer>()
                      {
                          new Signer()
                          {
                              Email = "Janedoe@acme.com",
                              Name = "Jane Doe",
                              RecipientId = "1",
                              RoleName = "Signer1",
                              Tabs = new Tabs()
                              {
                                  TextTabs = new List<Text>()
                                  {
                                      new Text()
                                      {
                                          DocumentId = docNumber,
                                          PageNumber = "1",
                                          XPosition = "100",
                                          YPosition = "100",
                                          Width = 120, 
                                          Value = "Some Tab Value " + docNumber
                                      }
                                  }

                              }
                          }
                      }
                  }
              }
          }
    }
}

There is the property Documents in the class EnvelopeDefinition, where you can add multiply documents. EnvelopeDefinition类中有Documents属性,您可以在其中添加多个文档。

I use the REST API Explorer from DocuSign when I want to check how to implement a feature. 当我想检查如何实现功能时,可以使用DocuSign的REST API Explorer

            enDef = new EnvelopeDefinition();
            doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(System.IO.File.ReadAllBytes(filename));
            doc.Name = DocName;
            doc.DocumentId = "1"; // increment this

            enDef.Documents = new List<Document>();
            enDef.Documents.Add(doc);

Added 添加

For multiply template roles also exists a property called TemplateRoles in the EnvelopeDefinition. 对于乘法模板角色,在EnvelopeDefinition中还存在一个名为TemplateRoles的属性。 There you can add more than one. 在那里您可以添加多个。

            tempRole = new TemplateRole();
            tempRole.Name = Rolename;

            enDef.TemplateRoles = new List<TemplateRole>();
            enDef.TemplateRoles.Add(tempRole);`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM