web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : 2UHPN2en5gM6evYZfmWCIk
Power Automate - Building Flows
Answered

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

Like (0) ShareShare
ReportReport
Posted on 16 Feb 2022 20:45:15 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...

I have the same question (0)
  • Medoomi Profile Picture
    523 on 02 Nov 2022 at 04:37:16
    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 28 Oct 2022 at 10:33:54
    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 21 Feb 2022 at 22:12:20
    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 21 Feb 2022 at 20:59:05
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2