Work with files and images

Completed

Dataverse has specific column data types for files and images. When using these data types, you must use separate actions to modify the column values and access the full column data contents.

The Upload a file or an image action is what you would use to modify an existing data row column with the contents of a file or an image. When creating new data rows, you would first use the Add a row action to create the row, then use the row ID on the upload action to modify the file or image columns.

The Download a file or an image action is what you would use to get full access to the binary data contents for either data type. You can retrieve the thumbnail and an image URL using the Get row by id action or the List rows action when working with image columns. The thumbnail contains the binary data for a small image version; you can use it in subsequent steps from the dynamic contents list. The thumbnail is in the dynamics contents column list with a name that matches the image column display name, for example, Product Image. You can also get a URL to download the image using the get or list rows actions. Remember that the download URL is intended for authorized users, and it wouldn't be appropriate to expose it to non-Dataverse users. This property doesn't show in the dynamic content, so you must do a workflow expression to access the value. The format of the item you would reference is column logical name plus "_url". The following assumes a column logical name of entityimage and gets the value from the results of a List rows action.

item()?['entityimage_url']

This would retrieve the following URL

/Image/download.aspx?Entity=sample_product&Attribute=entityimage&Id=27f5c0ed-b221-e811-a845-000d3a33a3ac&Timestamp=638371120614954283

Exercise - Work with files

In the following exercise, you create a flow that creates a new Product table row and uploads an image for the product. The flow then queries any new products and then downloads the image from each and uses AI Builder to generate a description.

Prerequisites

Access to an environment with Dataverse with sample apps installed if you want to do the following exercise.

Task - Create flow

  1. Navigate to Power Automate and select the correct environment.

  2. Select Create from the left navigation, and then select Instant cloud flow.

    Screenshot showing the create instant cloud flow button.

  3. Enter Add New Product for Flow name, select Manually trigger a flow, and then select Create.

    Screenshot showing the create instant flow dialog.

  4. Select the trigger, change the trigger name to Add product, and then select Add an input.

    Screenshot showing the add an input button.

  5. Select Text for input type.

  6. Name the input Product Name and select Add an input again.

  7. Select File for input type.

  8. The trigger should now have two inputs. Select the Insert a new step button and then select Add an action.

    Screenshot showing the add an action button.

  9. Search for "add row" and select Add a new row from the Microsoft Dataverse connector.

  10. Rename the step Add a new product row, select Products for Table Name.

  11. Type / in the Name field and then select Insert Dynamic Content.

    Screenshot showing the insert dynamic content option.

  12. Select Product Name from the dynamic content pane.

    Screenshot showing the selected product name.

  13. Select the Insert a new step button and then select Add an action.

  14. Search for upload image and select Upload a file or an image from the Microsoft Dataverse connector.

  15. Rename the action Upload product image, type / in the Content Name field and then select Insert Dynamic Content.

  16. Select File Content name from the dynamic content pane.

  17. Select Products for Table Name, type / in the Row ID field and then select Insert Dynamic Content.

  18. Select Product from the dynamic content pane.

  19. Select Product Image for Column Name.

  20. Type / in the Content field and then select Insert Dynamic Content.

  21. Select File Content contentBytes from the dynamic content pane.

  22. The upload product image action should now look like this image. Select the Insert a new step button and then select Add an action.

    Screenshot showing the upload product image action.

  23. Search for list rows and select List rows from the Microsoft Dataverse connector.

  24. Rename the step List products, select Products for Table Name, and then select Show all button.

  25. Paste this expression in the Filter Rows field. This setting filters the rows returned to only those created today.

    Microsoft.Dynamics.CRM.Today(PropertyName='createdon')

    Screenshot showing the filter rows value.

  26. Select the Insert a new step button and then select Add an action.

  27. Search download and select Download a file or an image from Microsoft Dataverse connector.

  28. Rename the step Download product image, select Products for Table Name.

  29. Type / in the Row ID field and then select Insert Dynamic Content.

  30. Select Product of the List products from the dynamic content pane.

    Screenshot showing the product ID.

  31. Power Automate should create For each and add the Generate description of an image action inside the For each. Select Product Image for Column Name.

  32. Select the Insert a new step button inside the For each and then select Add an action.

    Screenshot showing the add an action button inside the for each.

  33. Search for generate and select Generate description of an image from the AI Builder connector.

  34. Type / in the Image field and then select Insert Dynamic Content.

  35. Select File or image content from the dynamic content pane.

  36. Select the Insert a new step button inside the For each and then select Add an action.

    Screenshot showing the add an action button after the generate description step.

  37. Search for update row and select Update a row from the Microsoft Dataverse connector.

  38. Rename the step Update product description, select Products for Table Name, type / in the Row ID field, and then select Insert Dynamic Content.

  39. Select Product of the List products from the dynamic content pane.

  40. Select Show all.

  41. Locate the Product Description 1 field, type / and then select Insert Dynamic Content.

  42. Select the Description of the Generate description of an image from the dynamic content pane.

    Screenshot showing the AI builder image description.

  43. The completed flow should now look like this image. Select Save and wait for the flow to be saved.

    Screenshot showing the completed flow.

  44. Select Test

  45. Select Manually and then select Test.

  46. Type New Surface Laptop for Product Name, and select Import.

  47. Select any image from your machine.

  48. Select Run flow, after you select an image.

  49. Select Done.

  50. The flow run should succeed.

  51. Navigate to Power App maker portal and select the correct environment.

  52. Select Apps and launch the Asset Checkout application.

  53. Locate the New Surface Laptop row the flow created and open it.

  54. You should see the image you uploaded, and the description generated by AI Builder from the image.

    Screenshot showing the uploaded image, and the description generated by AI Builder.