Modifying and Handling Data
Congratulations! You've set up a secure connection and got information back from the platform. In the next steps we'll take a more complex task and break down how to action it.
Update a Recipient
Suppose we've sent out lots of documents to be signed by customers. Occasionally a document bounces off an old employee's email address or the client tells us a different person is the signer. We need to update the recipient — can we build a tool for this?
We'll need these arguments:
- the document id (a base64 string key)
- the old recipient email
- the new user email
- the new user first name
- the new user last name
Finding the Recipient ID
If the user passes a documentId we'll look up the recipient by email address.
Get Recipients for a Document
An easy way to get a sample documentId from Console is to go to the Document Details page. Get the document ID from the URL after /details/.
{
document(id: "ZG9jMWVmMjdkYWYtMGJlMS0xMWYwLWJiDVCXMDZlNDc2YTA3NTY5") {
id
recipients {
id
email
firstName
lastName
}
}
}
Test queries in the GraphiQL Explorer before writing code. If you run the above with an invalid ID you'll get a NOSUCHID warning:
{
"data": {
"document": null
},
"errors": [
{
"errorType": "WARNING",
"message": "NOSUCHID"
}
]
}
With a valid ID you'll see the recipients:
{
"data": {
"document": {
"id": "ZG9jMWVmMjdkYWYtMGJlMS0xMWYwLWJiYjUtMDZlNDc2YTA3NTY5",
"recipients": [
{
"id": "cmVjMjEwMzE4MjUtMGJlMS0xMWYwLWJiYjUtMDZlNDc2YTA3NTY5",
"email": "<recipient-email>",
"firstName": "Alex",
"lastName": "Test"
}
]
}
}
}
Most email servers allow the +x after your name in the email address. You can
use this for testing multiple recipients where the Template requires different people with different email addresses.