Background

I had a requirement where I wanted to fetch the signed document from DocuSign and add it as an attachment on the notes table for that contact in Dataverse. I knew DocuSign had the connectors support for cloud flows so obviously dived into it.

Problem

The structure of the flow was pretty straightforward as shown below:

First Flow Version

When the document is signed the flow will be triggered. We were storing the DocuSign sent document unique id on the contact record (assuming one contact will receive only one DocuSign document – you can certainly change this as per your needed); this unique id is called “Envelope ID“. But this flow soon failed with the following error:

Invalid character in field 'documentbody': '', hexadecimal value 0x03, is an invalid character.

Then I looked at the output generated by the “Get envelope documents” method and saw a JSON output. So soon I used “Parse JSON” action to parse the JSON and supplied it to the “Attach the document to the Contact record” action as shown below:

Second Flow with Parse JSON

But this flow also failed with the following error on “Parse DocuSign FileContent” action:

The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/pdf'.

This baffled me!!

Well I wasn’t giving up ๐Ÿ˜Š

Resolution

So, I started to closely look at the output generated by “Get envelope documents” action and it had header section with Content-Type as “application/pdf“. Ok now that makes sense.

But how do I make this happen ๐Ÿค”๐Ÿ’ญ.

COMPOSE comes to the rescue. So below is the new structure of my flow:

Basically the Notes document content is expecting only the base64 content and not the JSON which is what gets produced by the “Get envelope documents” action. So we have to parse out the content and content type from the JSON. This is accomplished by using Compose action type with the following expression for each of the actions:

Get Content:

outputs('Get_envelope_documents')?['body']['$content']

Get Content Type:

outputs('Get_envelope_documents')?['body']['$content-type']

Next, create Notes record linked to the contact with a document.

As you can see in the screenshot above the output of the “Get Content” compose action is assigned to Document on Notes and output of “Get Content Type” compose action is assigned as Mime Type; making sure when the note gets created it will have a document associated with it. Oh and don’t forget to ad the regarding on the contact or any other entity you are working with on the notes creation.

When a user signs the document they had received from DocuSign it will be marked as completed which will trigger this cloud flow; creating a notes record on the Contact with an attached signed copy of the DocuSign document as shown below:

And that’s it. Hope this helps.

Don’t forget to subscribe to my Power Platform ProDev Newsletter

Subscription received!

Please check your email to confirm your newsletter subscription.

For more content subscribe to my blogs and follow me on:

Become one of my sponsors on GitHub

1 comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: