The post is motivated by the case Rhia Wieclawek wrote about on her Twitter. Her case is possibly more complex, but the general question was: how can I use the signature from the Nintex Mobile inside a document being generated by the nintex document generation action? Unfortunately this is not yet feasible only using Nintex products. This is because Nintex Workflow for Office 365 is not handling correctly the binary data (it loses null bits) so what I proposed was to use microsoft flow.
The process
- User sings a form in Nintex Mobile.
- The signature along with the form is saved in a SharePoint list.
- Then the Nintex workflow on item's creation is triggered.
- It builds a JSON, that is a request body, then calls Microsoft Flow, passing:
- form's title and
- base64 encoded signature from a multi-line text field.
- Flow receives the call, starts and uploads signature to the images library, converting it from base64 to binary.
- In resposne Flow sends the URL to the created file.
- Nintex receives the response and attempts to generate a document, having an image defined, that is the signature, having a variable set as a path (that is returned by Flow).
- Finally it generates a PDF with the signature inside.
Realization
Microsoft Flow
Its purpose is simple - get base64 encoded string and convert it into binary, then upload to a specified document's library. It is being invoked by a "Web Request" message, that should contain a valid JSON string, containing title of a form (it is using it to set file's name) and base64 encoded string.
{
"Title": "Form's title or other text variable",
"Signature": "The base64 encoded signature image"
}
After that it immediately calls SharePoint (using "Create File" action) and uploads the file, using the expression "Base64ToBinary":
base64ToString(triggerBody()?o'Signature'])
After that it send back in "Response" action the uploaded file path:
Nintex Workflow
Is being triggered once a new item is created - user sends the signed form. Workflow purpose is to build a JSON that is a request body, and that is in a correct format - the one that Microsoft Flow workflow is expecting.
Then it calls the Flow, using the "Web Request" action:
And stores the "Response Content" in a text variable.
Then it builds an absolute path to the uploaded signature image, by joining workflow context's current site URL with the text received after Web Request call - the site relative path of the uploaded file.
Next it generates the document.using the Document Generation action.
The results
The working proof of concept:
You can find attached exported Nintex Workflow and Flow files.