Getting documentid for SIGNED document into Notification
Monday, June 26, 2023 at 10:51amWe 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
Reply to: Getting documentid for SIGNED document into Notification
Monday, June 26, 2023 at 11:55amHi 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
Reply to: Getting documentid for SIGNED document into Notification
Monday, June 26, 2023 at 12:57pmThank you! Will go with option 2 and just check for the 1st document without an empty approval array