cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Axal
Post Patron
Post Patron

Upload file attachments to Dynamics 365 Finance

Hi,

 

I'm creating PowerApps which utilize the attachments control, which going to be uploaded to my Dynamics 365 Finance, with help of Flow, by using D365 Finance data connector - Create records.

 

This guy:

Axal_0-1622999872186.png

Following some tutorial, in PowerApps, when I have the attachment control, then I should do these steps:

1. Add Image control (for my temporary holder)

2. Add this code for the image property :

 

Last(AttachmentsCtrl.Attachments).Value

 

3. Add button to convert the image to binary, using this code:

 

Set(tempFile, JSON(ImageTemp.Image, JSONFormat.IncludeBinaryData));
Set(FileUpload, 
    Mid(tempFile,Find(",",tempFile)+1,Len(tempFile)-Find(",",tempFile)+1)
);

 

 

When I'm using it to upload a small txt file, contain only 1 word, the result of those 2 variables looks fine with me :

tempFile -> data:text/plain:base64,VGVzdGluZw=="

FileUpload -> VGVzdGluZw=="

 

Then I will just need to create Flow to pass this FileUpload, along with my key fields (I specified all the keys correctly when I checked from the Flow)

 

However my Flow failed, with error -> An error has occurred. Exception has been thrown by the target of an invocation. Cannot convert the literal 'VGVzdGluZw=="' to the expected type 'Edm.Binary'.

 

The Output error is like this :

{
  "status"400,
  "message""An error has occurred.  Exception has been thrown by the target of an invocation.  Cannot convert the literal 'VGVzdGluZw==\"' to the expected type 'Edm.Binary'.\r\nclientRequestId: xxxx-xxxx-xxxx-xxxx--xxxxx",
  "error": {
    "message""An error has occurred.  Exception has been thrown by the target of an invocation.  Cannot convert the literal 'VGVzdGluZw==\"' to the expected type 'Edm.Binary'."
  },
  "source""xxxxxxxaos.cloudax.dynamics.com",
  "errors": []
}

 

May I know what's wrong with this ? 

 

Thanks.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Axal
Post Patron
Post Patron

Sorry, it was the formula error ->

Set(FileUpload, 
    Mid(tempFile,Find(",",tempFile)+1,Len(tempFile)-Find(",",tempFile)+1)

should be "-1" in the end 

 

Solved.

Thanks

View solution in original post

2 REPLIES 2
Axal
Post Patron
Post Patron

Sorry, it was the formula error ->

Set(FileUpload, 
    Mid(tempFile,Find(",",tempFile)+1,Len(tempFile)-Find(",",tempFile)+1)

should be "-1" in the end 

 

Solved.

Thanks

View solution in original post

v-LilyW-msft
Microsoft
Microsoft

Hi @Axal 

Glad to see your problem solved, thank you for sharing the solution.

Best Regards

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,793)