Power Automate CDS trigger bug; DocumentBody truncated at 16,000,000 characters

Recently I had a client contact me about an issue in Dynamics where some files uploaded, weren’t able to be reteived. The system was working fine most of the time, and uploads of PDF’s, JPG’s etc were working just fine, but the odd file wouldn’t work. The common denomitator was the files that had failed were always on the larger size, over 12MB.

Background:

This solution has a Power Automate flow that runs on the Common Data Service trigger for record creation. When a note is created, the flow will add some metadata or a watermark to the file based on the mime type, then reattach the image or PDF file. This way if the source file is downloaded the ownership is clear.

So while was this mostly working fine, some uploads were failing. The client had been uploading the occasional larger PDF file (>12MB). The first thing that came to mind was the Dynamics attachment file size limit, as the default size is 5MB, yes easy fix! …. No ….

Upon inspection this was already set a large number (50 MB) so that ruled ou the easy fix.


Figure: Maximum file size is more than big enough

After lots of head scratching I ended up copying the documentbody (Base64 encoded) into a Text Editor and the length of the string was exactly 16,000,000 characters:


Figure: triggerbody/documentbody is exactly 16,000,000 chars, hmmmm

Then adding a second Get Record action revealed some interesting details:


Figure: Get_record/documentbody is greater than 16M records, looking much better

So what just happened here?

The CDS Trigger is restricting the Document Body field to 16 million characters, but if the same record is loaded with CDS Get Record no such restriction appears to be in place, in this example 20,384,676 characters which is bang on the reported filesize property of 15,288,507  base64 (20,384,676 / 4 * 3 ==  15,288,507).

The moral of the story

If you’re getting truncation of data using a CDS trigger, try reloading the record with Get Record.

 

 

Related Post

2 thoughts on “Power Automate CDS trigger bug; DocumentBody truncated at 16,000,000 characters

  1. Thanks for sharing this pearl of wisdom…I wonder if this restriction applied to the now deprecated Dynamics connector…

Leave a Reply

Your email address will not be published. Required fields are marked *