Save and Retrieve DataVerse Email Attachments in a Canvas App and Power automate -(Saving attachments) Part 2

On part 1 of this article , I have explained how to pass the attachments from the canvas app to power automate; In this part will be explaining in details how to save an attachments to an Email DataVerse record. We have explained in part 1 that we are passing attachments collection as first parameter and Email Id as second parameter.

So Lets get started when you click Action->Power Automate-> Create new flow it opens power automate button , you can select a variety of templates or start from blank.

Go ahead and give your flow a name and the first action should be PowerApps

Add a compose data operation and rename it files data; Click inside the inputs and click on Ask in PowerApps and this will insert an input parameter to your flow.

Add another compose data operation to Grab the Email Id to which you will be attaching your list of attachments.

Next Step we need to ParseJson for the FilesData Compose data operation and pass Schema Below:

JSON SCHEMA:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "Name": {
                "type": "string"
            },
            "Value": {
                "type": "string"
            }
        },
        "required": [
            "Name",
            "Value"
        ]
    }
}

Then Add an Apply to each .

Add a Compose and pass the Value

Value looks like: data:image/png;base64,bas64veryLONGSTRING

So we need to do a first split to get the bas64veryLONGSTRING and this is handled by compose 2

Add another Compose 2 with the Expression

split(outputs('Compose'),',')

Then Click Add a new row, Choose Table Name: Attachments

For Attachment(Attachments) highlighted above it looks like mandatory but actually you need to pass an ” empty expression and it works.

Next Tricky part when you set the attribute Entity it gives you a selection either Email Activity or Email Template; and first I have tried of course using Email Activity but I was presented with the below error:

Well then do not choose any of them Just click on Enter Custom Value and Type email.

Next you need to pass the item you are linking your attachment to as below:

For Name just pass the Name property from your JSON object

For Body we need to pass the bas64veryLONGSTRING which we have previously made a split operation to get its value and the below expression will be getting it:

outputs('Compose_2')[1]

We need to Extract the Mime Part from the Value data:image/png;base64,bas64veryLONGSTRING

So we use below expression and this will be responsible for extracting image/png

Split(split(outputs('Compose_2')[0],';')[0],':')[1]

In the next part I will be explaining how to view emails in CDS and Display the List of attachment.

https://wordpress.com/post/onlinemgblog.wordpress.com/902

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: