nweese | Posts: 10

Editing Field Values using /api/packages/{packageId}/clone right

0 votes
Currently trying to customize my package.... It is an existing template on my sandbox and I would like to be able to customize the fields each time I clone the package. Is this possible? This is the current JSON payload I am sending... the signer information works but the fields are not working. They are "Labels" on my template with Name's as shown in the fields portion and no value.
    var payload = {
      "status": "SENT",
      "name": "Package created from template through REST API",
      "roles":
        [
          {
            "id": "5e4f1718-24f2-424f-94bc-9de4bc183680",
            "signers":
              [
                {
                  "id": "placeholderId2",
                  "firstName": "Nicole",
                  "lastName": "Weese",
                  "email": "[email protected]",
                }
              ]
          }
        ],
      "documents":
        [
          {
            "id": "default-consent"
          },
          {
            "fields":
              [
                {
                  "extract": true,
                  "value": "12345678790",
                  "name": "SSN"
                },
                {
                  "extract": true,
                  "value": "12345678790",
                  "name": "SSN2"
                },
                {
                  "extract": true,
                  "value": "12345678790",
                  "name": "recipientPhone"
                },

              ],
            "extract": true,
            "id": "f13e975b4404f250fb68feefd3db66f3d225c2dfb0840838",
          },

        ]
    }


Duo_Liang | Posts: 3776

Reply to: Editing Field Values using /api/packages/{packageId}/clone right

0 votes
Hi there, Field Injection can only be processed by our Doc Engine the moment when the document was uploaded to OneSpan Sign, so since Template means you have uploaded your document to OSS already, it's not possible to update your fields when creating package from this template. So a workaround is, #1. when creating template, you can use Label Field to customize your text content instead of Field Injection(guidance here), and use Position Extraction to locate your labels fields since you are currently using PDF form fields.
"documents": [
    {
      "approvals": [
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "extract": true,
              "subtype": "FULLNAME",
              "name": "Signature1"
            },
            {
              "name":"SSN1",
              "extract":true,
              "type":"INPUT",
              "value":null,
              "subtype":"LABEL"
            }
          ],
          "role": "Signer1"
        }
      ],
      "extract": true,
      "name": "Sample Contract"
    }
  ]
#2. every time you created package from template: First, you leave the package status to "DRAFT"; Then you set values for labels fields by updating them. Currently, there's no batch updating fields API, so I guess you will have to update your fields one by one calling this API (you can use field's name to identify it when looping through all your fields):
PUT /api/packages/{packageId}/documents/{documentId}/approvals/{approvalId}/fields/{fieldId}
use modified value as payload
Finally, sent your package. Hope this could help! Duo

nweese | Posts: 10

Reply to: Editing Field Values using /api/packages/{packageId}/clone right

0 votes
So this is my original payload when hitting the /api/packages/{packageId}/clone route...
    var payload = {
      "status": "DRAFT",
      "name": "Package created from template through REST API",
      "roles":
        [
          {
            "id": "5e4f1718-24f2-424f-94bc-9de4bc183680",
            "signers":
              [
                {
                  "id": "placeholderId2",
                  "firstName": "Nicole",
                  "lastName": "Weese",
                  "email": "[email protected]",
                }
              ]
          }
        ],
      "documents":
        [
          {
            "id": "default-consent"
          },
          {
            "id": "f13e975b4404f250fb68feefd3db66f3d225c2dfb0840838",
            "approvals": [
              {
                "fields": [
                  {
                    "type": "SIGNATURE",
                    "extract": true,
                    "subtype": "FULLNAME",
                    "name": "Signature1"
                  },
                  {
                    "name":"dateOfBirth",
                    "extract":true,
                    "type":"INPUT",
                    "value":null,
                    "subtype":"LABEL"
                  }
                ],
                "role": "Signer1"
              }
            ],
            "extract": true,
            "name": "Sample",
          },

        ]
    }
is this correct? Should role be placeholderId2? For your PUT route, you said /fields, but say there is no batch field value editing. Does this mean that my payload needs to have an id attached to it?
    let updatePayload = {
      "name": "dateOfBirth",
      "data": null,
      "id": "g2AWMEVZaY42",
      "top": 323.0,
      "left": 289.0,
      "width": 208.0,
      "height": 25.0,
      "page": 2,
      "type": "INPUT",
      "value": "June 2 1992",
      "binding": null,
      "subtype": "LABEL"
    }
or should I be hitting the /fields/{fieldId} with a simplifiied JSON object
    let updatePayload = {
      "name": "dateOfBirth",
      "value": "June 2 1992",
    }

Duo_Liang | Posts: 3776

Reply to: Editing Field Values using /api/packages/{packageId}/clone right

0 votes
Hi there, Sorry for not putting this clear.
"documents": [
    {
      "approvals": [
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "extract": true,
              "subtype": "FULLNAME",
              "name": "Signature1"
            },
            {
              "name":"SSN1",
              "extract":true,
              "type":"INPUT",
              "value":null,
              "subtype":"LABEL"
            }
          ],
          "role": "Signer1"
        }
      ],
      "extract": true,
      "name": "Sample Contract"
    }
  ]
#1. This example I sent is for creating templates with label fields instead of using field injection, and you also need to assign field ID here. #2. when making clone call, you can't specify label values, so that's why I said you'll have to update your label fields one by one after clone your template and leave it in DRAFT. #3. the PUT call to update label fields should include /fields/{fieldId} to specify which field you want to update, it was a mistake made by me. And the payload should be a fully dressed one instead of simplified one. Duo

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off