Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Retrieve Dataverse attachments - Error on "Null" attachment(s) after deletion

(0) ShareShare
ReportReport
Posted on by 523

I have a working Flow which retrieves multiple attachments associated with a single record in a "Projects" Table. These attachments are saved in the Note Table in Dataverse.

After filtering the Note Table, I am using a Compose data operation to import these attachments using the following code:

 

{
 "Name": @{items('Apply_to_each_3')?['filename']},
 "ContentBytes": @{base64ToBinary(items('Apply_to_each_3')?['documentbody'])}
}

 

The output is then appended to an array variable.

 

Everything works fine, except when one of those attachments has been deleted (in a powerapps form where those attachments are displayed). When this happens, the record (for the deleted attachment) in the Notes Table seems to remain, only the output is "Null", which causes the base64ToBinary conversion to fail & the entire flow fails. For example in a record where two attachments remain, and one of those attachments has previously been deleted, the "apply to each_3" step attempts to run three times (instead of two). Two of those steps work, one of them fails with "Null" as the output.

 

If it helps, I am retrieving attachments by filtering the Notes Table with the following code (filtering by GUID of the projects Table):

 

_objectid_value eq @{items('Apply_to_each_2')?['cr6a2_projectid']}

 

 

How can I solve this? I imagine I would either have to avoid creating attachments in the Notes Table with Null as the content, or avoid retrieving those attachments with Null as the content...

  • Medoomi Profile Picture
    523 on at
    Re: Retrieve Dataverse attachments - Error on "Null" attachment(s) after deletion

    I don't know if it helps, but here is my condition to exclude the null value:

    Medoomi_0-1667363769168.png

     

  • Krishna09 Profile Picture
    234 on at
    Re: Retrieve Dataverse attachments - Error on "Null" attachment(s) after deletion

    Even I am facing same problem. Can you please share what condition have you used? I used flowing condition and below is my flow. I still get null value error.

    Krishna09_0-1666953152411.png

    Krishna09_1-1666953165125.png

    Krishna09_2-1666953215912.pngKrishna09_3-1666953227084.png

     

     

  • Verified answer
    Medoomi Profile Picture
    523 on at
    Re: Retrieve Dataverse attachments - Error on "Null" attachment(s) after deletion

    OK, the answer was simpler than I expected. I took the advice in the Microsoft document Getting errors with null fields. All I needed was a condition action to exclude null values from the output of the filtered Note Table.

  • Medoomi Profile Picture
    523 on at
    Re: Retrieve Dataverse attachments - Error on "Null" attachment(s) after deletion

    Given that the flow breaks at the base64ToBinary step, I attempted to write an if clause which would by-pass the base64ToBinary step if the content was 'Null.' My code was as follows:

    {
     "Name": @{items('Apply_to_each_3')?['filename']},
     "ContentBytes": @{if(equals(items('Apply_to_each_3')?['documentbody'],'Null'),'Null',base64ToBinary(items('Apply_to_each_3')?['documentbody']))}
    }

    It seems the if clause still doesn't by-pass the base64ToBinary step because my error output is as follows:

    InvalidTemplate. Unable to process template language expressions in action 'Compose_All_Attachments' inputs at line '0' and column '0': 'The template language function 'base64ToBinary' expects its parameter to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#base64ToBinary for usage details.'.

    Is there another way to by-pass the base64ToBinary step when the content is 'Null'

    Or another way to circumvent this problem?

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1