mcharski

Getting documentid for SIGNED document into Notification

0 votes

We currently received notifications when the package is completed "PACKAGE_COMPLETE" however the documentid property is null. 

when I get the package contents I can get the list of documents but the status on the documents doesn't show which one is the signed one. ( /api/packages/{{packageid}} )

I want to get only the document that was signed and none of the ancillary documents, however we need to know the documentid to get it.

/api/packages/{{packageid}}/documents/{{documentid}}/pdf

I'm using the following to get the first document with an approval node populated, but there should be a better way to determine the documentid(s) that were just signed.

output application/json
---
((payload.documents filter ((item, index) -> item.approvals !=[] and item.approvals.signed !=null)) map ((item, index) -> {
    id: item.id,
    name: item.name
} ))[0]

1. how do we get the documentid property to populate in the response notification for PACKAGE_COMPLETE

2. how do we have the status of the document reflect the current status

3. is there a better way to get the signed document from package


Approved Answer

Reply to: Getting documentid for SIGNED document into Notification

1 votes

Hi mcharski,

 

Thanks for the detailed information!

For your questions:
1. PACKAGE_COMPLETE event doesn't populate documentId because it's a transaction level event and not related to a specific document. On the contrary, events like DOCUMENT_SIGNED do have documentId value. Monitoring DOCUMENT_SIGNED event instead of PACKAGE_COMPLETE could be an option, but I personally don't recommend this because relying on multiple callback notifications could be more error prone.

 

2. The logic you currently use looks good to me. Without testing the code, just one thing here:
 ((payload.documents filter ((item, index) -> item.approvals !=[] and item.approvals.signed !=null)) map ((item, index) -> {
    id: item.id,
    name: item.name
} ))[0]

Should you loop through the item.approvals array, and return true if any approval.signed !=null? (considering there could be optional signatures, it's not necessary to require all approvals signed)

 

3. Another solution I can come up with is to flag the document during transaction creation, you can store custom data under "documents" > "data"

{

  ......,
  "documents": [
    {
      "name": "Document1",
      "data": {
        "hasSignature": true
      }

    },
    {
      "name": "Document2",
      "data": {
        "hasSignature": false
      }

    }
  ],
  "name": "Example Package",
  "language": "en",
  "description": "New Package",
  "status": "SENT"
}

If you want to follow this path, note that if you are using default-consent form, because you can't add custom data for default-consent in this call, don't forget to download it as well.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Getting documentid for SIGNED document into Notification

0 votes

Thank you! Will go with option 2 and just check for the 1st document without an empty approval array


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