简体   繁体   English

具有docusign_rest的自定义模板字段

[英]Custom template fields with docusign_rest

I'm using the docusign rest gem to create and send DocuSign envelopes. 我正在使用docusign rest gem创建和发送DocuSign信封。 But I'm having problems having custom fields I have set on my template to show up. 但是我在模板上设置要显示的自定义字段时遇到问题。 I have 2 signers on my template, that have common fields to both of them so I had to set up each custom field twice since DocuSign doesn't allow for shared fields it seems. 我的模板上有2个签名者,它们两个都有共同的字段,所以我似乎不得不设置每个自定义字段两次,因为DocuSign似乎不允许共享字段。

在此处输入图片说明

在此处输入图片说明

This is the API call I'm doing when setting up my envelope, as per the DocuSign API docs: 根据DocuSign API文档,这是我在设置信封时执行的API调用:

custom_fields = {
      textCustomFields: [
        {
          name: "host_address",
          value: "Testing Host Address",
          required: "true",
          show: "true",
        },
        {
          name: "host_civil_status",
          value: "Host Civil Status",
          required: "true",
          show: "true",
        },
        {
          name: "host_id_number",
          value: "123HOSTID",
          required: "true",
          show: "true",
        },
        {
          name: "host_tax_number",
          value: "123HOSTTAX",
          required: "true",
          show: "true",
        },
        {
          name: "nomad_address",
          value: "Testing Nomad Address",
          required: "true",
          show: "true",
        },
        {
          name: "nomad_civil_status",
          value: "Nomad Civil Status",
          required: "true",
          show: "true",
        },
        {
          name: "nomad_id_number",
          value: "123NOMADID",
          required: "true",
          show: "true",
        },
        {
          name: "nomad_tax_number",
          value: "123NOMADTAX",
          required: "true",
          show: "true",
        },
        {
          name: "property_addres",
          value: booking.listing.property.full_address,
          required: "true",
          show: "true",
        },
        {
          name: "property_address",
          value: booking.listing.property.full_address,
          required: "true",
          show: "true",
        },
        {
          name: "property_deposit",
          value: (booking.deposit * booking.price).to_s,
          required: "true",
          show: "true",
        },
        {
          name: "property_description",
          value: "Property Description",
          required: "true",
          show: "true",
        },
        {
          name: "property_start_date",
          value: booking.start_date.strftime("%d/%m/%Y"),
          required: "true",
          show: "true",
        },
        {
          name: "property_end_date",
          value: booking.end_date.strftime("%d/%m/%Y"),
          required: "true",
          show: "true",
        },
        {
          name: "property_stay_length",
          value: distance_of_time_in_words(booking.start_date, booking.end_date),
          required: "true",
          show: "true",
        },
        {
          name: "property_montly_rent",
          value: booking.price.to_s,
          required: "true",
          show: "true",
        },
      ]

    }
    @envelope = client.create_envelope_from_template(
      status: 'sent',
      email: {
        subject: "The test email subject envelope",
        body: "Envelope body content here"
      },
      template_id: "77xxxxxxxxxxxxxxxxxxxxxxxxxx",
      signers: [
        {
          embedded: true,
          name: booking.listing.user.name,
          email: booking.listing.user.email,
          role_name: 'Host',
        },
        {
          embedded: true,
          name: booking.user.name,
          email: booking.user.email,
          role_name: 'Nomad',
        }
      ],
      custom_fields: custom_fields
    )

Unfortunately, there are two different objects in the DocuSign system that essentially have the same name of "custom field." 不幸的是,DocuSign系统中有两个不同的对象,它们实际上具有相同的“自定义字段”名称。 You're using the wrong one. 您使用的是错误的。

The two objects are: 这两个对象是:

1. Metadata custom data fields 1.元数据自定义数据字段

These objects come in two flavors: textCustomFields and listCustomFields. 这些对象有两种形式:textCustomFields和listCustomFields。

These objects can be set at the account level to require that every every (or some) envelopes sent include additional metadata at the envelope level. 可以在帐户级别设置这些对象,以要求发送的每个(或某些)信封都必须在信封级别包含其他元数据。

The objects can also be set at the envelope level programmatically. 还可以通过编程在信封级别设置对象。

These "custom fields" are not visible to the signer. 这些“自定义字段”对签名者不可见。 They are not fields (tabs) visible on the documents. 它们不是文档上可见的字段(选项卡)。 They are associated with the envelope as additional metadata. 它们与信封相关联,作为其他元数据。 These are the type of custom fields that your code example is using. 这些是您的代码示例使用的自定义字段的类型。

Adding/listing the custom fields set at the account level: docs. 添加/列出在帐户级别设置的自定义字段: docs。

Adding a custom metadata field to an envelope: use the customFields attribute of the envelope definition. 将自定义元数据字段添加到信封:使用信封定义的customFields属性。

2. Customized tabs (fields) 2.自定义标签(字段)

A customized tab (called a 'field' in the DocuSign web tool) is a version of a DocuSign tab (text tab, sign here tab, date tab, etc) that has been customized. 自定义选项卡(在DocuSign Web工具中称为“字段”)是已自定义的DocuSign选项卡(文本选项卡,此处签名的选项卡,日期选项卡等)的版本。 Then, later, instead of re-customizing another instance of the tab, the customized tab can be re-used. 然后,以后,无需重新自定义选项卡的另一个实例,而可以重新使用自定义的选项卡。

This is what you want to use. 这就是您使用的。

To use the API to list them, update them, etc: docs. 要使用API​​列出它们,更新它们,等等: docs。

To use them in a document 在文档中使用它们

Disclaimer: I'm reading the docs, I have not tried this. 免责声明:我正在阅读文档,但没有尝试过。 Please add a comment after you try it: 在尝试后添加评论:

  1. You will need the customTabId for the customized tab. 您将需要customTabId作为自定义标签。 Use the CustomTabs::list API call. 使用CustomTabs :: list API调用。
  2. You also need to know the base tab type: Text, etc. Use the type value which is also returned by the CustomTabs::list API call. 您还需要知道基本的选项卡类型:文本等。使用type值也由CustomTabs :: list API调用返回。
  3. Then, when creating your document, for each recipient who gets a customized, tab, create the tab as usual, but include the customTabId as part of the tab's definition. 然后,在创建文档时,对于每个获得自定义标签的收件人,照常创建标签,但是将customTabId包含在标签定义中。 Eg, see the text tab object definition in Envelopes::create API call. 例如,请参阅Envelopes :: create API调用中的text选项卡对象定义。

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

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