Convert Dataverse file column content

Convert Dataverse file column content to base 64 format | Power Apps | Canvas Apps

Table of Contents

In this blog, we will show how to convert the value of a Dataverse file column into base format in Power Apps. You only require 3 controls and the JSON function.

Step 1. Add image, button and text controls

In the screen where the base64 format is required, add an image, button and text controls.

Turn your ideas into digital solutions

Our team guides you step by step to build custom apps in Power Platform.

Add image, button and text controls Column

Step 2. Set up value for the Image control

Select the image and in the “image” property, add the following formula:

Image Control Column

Last(Table_Attachments).File.Value

Last(Table_Attachments) can be replaced by ThisItem. If the image is in a gallery, or by a variable name that contains the file you want to convert.

Step 3. Set a variable with the base64 content

In the button, add the following code on the OnSelect property:

Set base64 content Column
				
					Set(
    varFiletoBase64,
    JSON(
        Image1.Image,
        JSONFormat.IncludeBinaryData
    )
)

				
			

Step 4. Use the variable

Now the varFiletoBase64 variable contains the representation of the file in base64 format. You can use it in the application as required. 

For this simple example we are just displaying it in the text control:

Are you ready to discover the joy of automation?

Whether you have a project in mind or just want to know how we can help, we’re happy to have a conversation

Text Control Column

Conclusion

Power Apps allows converting Dataverse files into base64 format by using the JSON PowerFx function in combination with the image control and save this result into a variable that can be used across all the application. Contact us if you have any questions or if you’d like some help on Power Apps or PowerFx!

Author
Power Platform Consultant | Business Process Automation Expert
Microsoft Certified Power Platform Consultant and Solution Architect with 4+ years of experience leveraging Power Platform, Microsoft 365, and Azure to continuously discover automation opportunities and re-imagine processes.