如何使用 API 从 Power Automate 填充 DocuSign 中的文档自定义字段值

How do I populate Document Custom Field values in DocuSign from Power Automate using API

我正在使用 Power Automate 将文档从共享点列表传递到 Docusign,以便通过 API 在本文档之后进行签名:https://www.docusign.com.au/blog/get-the-flow-sending-docusign-envelopes-microsoft-power-automate。这些文件不是标准模板,文件可以包含任何内容,除了用于姓名、职位和公司详细信息的标准“签名块”,以及签名人的签名和日期。在传递给 Docusign 的文档中,每一个都有一个 Autoplace 占位符(标签)。我已将文档自定义字段配置为 DocuSign 中字段“名称”、“标题”和“公司”的“文本字段”,并使用定义的 AutoPlace 标签与正在传递的文档中的 AutoPlace 标签对齐。当查看文档以在 DocuSign 中签名时,这些字段会出现在 DocuSign 文档中,但不会填充它们。

如何使用 API 传递这些字段的数据值?

这是 Power Automate 自定义连接器中 Swagger 代码的接收部分。

        schema:
          type: object
          properties:
            documents:
              type: array
              items:
                type: object
                properties:
                  documentBase64: {type: string, description: documentBase64}
                  documentId: {type: string, description: documentId}
                  fileExtension: {type: string, description: fileExtension}
                  name: {type: string, description: name}
                  order: {type: string, description: order}
              description: documents
            emailSubject: {type: string, description: emailSubject}
            emailBlurb: {type: string, description: emailBlurb}
            recipients:
              type: object
              properties:
                signers:
                  type: array
                  items:
                    type: object
                    properties:
                      email: {type: string, description: email}
                      name: {type: string, description: name}
                      title: {type: string, description: title}
                      company: {type: string, description: company}
                      recipientId: {type: string, description: recipientId}
                      roleName: {type: string, description: roleName}
                      routingOrder: {type: string, description: routingOrder}
                  description: signers
              description: recipients
            status: {type: string, description: status}

答案是使用文本标签,而不是自定义字段。 textTabs 是“选项卡”的属性,它们是“收件人”的属性,而不是“文档”的属性。按照此文档:https://developers.docusign.com/docs/esign-rest-api/how-to/set-envelope-tab-values/ 我能够为 DocuSign 自定义连接器创建一个 swagger 'recipients' 架构,它提供了对选项卡的相当重要的控制,包括字体样式、锚点偏移等。然后在您的 Power Automate 中(流程)您可以根据需要使用尽可能多的文本标签(字段)构建您的 JSON。只需确保文档中的占位符与 json 中的“anchorString”属性 匹配(这让我追查了一段时间的错误!)。

新架构:

            recipients:
              type: object
              properties:
                signers:
                  type: array
                  items:
                    type: object
                    properties:
                      email: {type: string, description: email}
                      name: {type: string, description: name}
                      recipientId: {type: string, description: recipientId}
                      roleName: {type: string, description: roleName}
                      routingOrder: {type: string, description: routingOrder}
                      tabs:
                        type: object
                        properties:
                          textTabs:
                            type: array
                            items:
                              type: object
                              properties:
                                anchorString: {type: string, description: anchorString}
                                anchorUnits: {type: string, description: anchorUnits}
                                anchorXOffset: {type: string, description: anchorXOffset}
                                anchorYOffset: {type: string, description: anchorYOffset}
                                bold: {type: string, description: bold}
                                font: {type: string, description: font}
                                fontSize: {type: string, description: fontSize}
                                locked: {type: string, description: locked}
                                tabId: {type: string, description: tabId}
                                tabLabel: {type: string, description: tabLabel}
                                value: {type: string, description: value}
                            description: textTabs
                        description: tabs
                  description: signers
              description: recipients

在使用 DocuSign 指南创建连接器时,要在 'Definition' 选项卡的 'Import from Sample' 处导入 DocuSign 自定义连接器:https://www.docusign.com.au/blog/get-the-flow-sending-docusign-envelopes-microsoft-power-automate,您可以将以下内容导入“正文” :

{
    "documents": [
      {
        "documentBase64": "[variable]",
        "documentId": "1",
        "fileExtension": "txt",
        "name": "Doc1",
        "order": "1"
      }
    ],
    "emailSubject": "Test Envelope 1",
    "emailBlurb": "This is the email body",
    "recipients": {
      "signers": [
        {
          "email": "[enter signer email address]",
          "name": "[enter signer name]",
          "title": "[enter signer title]",
          "company": "[enter signer company name]",
          "recipientId": "1",
          "roleName": "Signer 1",
          "routingOrder": "1",
            "tabs": {
              "textTabs": [
                {
                "anchorString": "/sn1/",
                "anchorUnits": "pixels",
                "anchorXOffset": "5",
                "anchorYOffset": "-9",
                "bold": "true",
                "font": "helvetica",
                "fontSize": "size11",
                "locked": "false",
                "tabId": "signer1_name",
                "tabLabel": "Signer1 Name",
                "value": ""
              }
            ]
          }
        }
      ]
    },
    "status": "sent"
  }