cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asetser
Frequent Visitor

Sending SQL Image to Flow

I'm having an issue that I'm not finding the solution for.

 

A little bit of history/details:
I have 2 apps that use the same SQL data, one is for our service technicians that are in the field and one is for the office team. The app for the tech's is where they get their daily assignments, where they track their status updates on each assignment, where they add/update the equipment for each site they work at, where they create quote of repairs (QR), where they create their daily service work orders (SWO). For the QR and SWO, they data they enter in the app is sent to a Flow that populates a Word Template and emails it to the appropriate people. On the SWO, there are 2 pen inputs (tech and customer signatures) and 1 media/image capture (store stamp image required for specific sites/customers). I send the data to the flow using JSON with 2 nested tables within the JSON (as notes can be repeating and materials can be repeating). It also writes all the data to SQL. Since the techs need to get a customer signature, the logic is set that they can only create the SWO on the day the work it (they have to have status updates on that dispatch that day).

 

I have no issues with this. Works great.

 

My issue:

When the office needs to create an SWO because the tech failed to (or because they've lost it), their app has to read the signatures and store stamp from the SQL tables (it reads all data from the SQL tables, but these are the only 3 giving me issues). All 3 fields are saved as both image data type and varbinary(max) data type (for now, as I did not know which one I could get to work). I've got a gallery view of all assignments that were worked by the techs in the last 7 days. I added images to ensure the SQL image fields display successfully, and they do (using ThisItem.ImageFieldName for each one in the Image setting). However, when I try to send the image fields to a Flow, my flow fails for invalid image format.

I know when I view the image field in SQL, it shows as text. So Power Apps is able to translate it to the picture. How can I translate it within Power Apps so it's a valid picture format when it sends it to the flow?

1 ACCEPTED SOLUTION

Accepted Solutions
asetser
Frequent Visitor

I was able to figure this out. In my Flow, after parsing the JSON, I then did a compose for each picture with this logic:

dataUriToBinary(body('ParseJSON')?['FieldNameHere'])

 

When the flow was getting the SQL varbinary field, it was getting this at the beginning of the field:

data:application/octet-stream

 

What it needed to get was this:

data:image/png

 

So by updating my compose steps to the following logic, all flows are successfully working and documents are being created:

dataUriToBinary(replace(body('ParseJSON')?['FieldNameHere'], 'application/octet-stream', 'image/png'))

View solution in original post

2 REPLIES 2
asetser
Frequent Visitor

I was able to figure this out. In my Flow, after parsing the JSON, I then did a compose for each picture with this logic:

dataUriToBinary(body('ParseJSON')?['FieldNameHere'])

 

When the flow was getting the SQL varbinary field, it was getting this at the beginning of the field:

data:application/octet-stream

 

What it needed to get was this:

data:image/png

 

So by updating my compose steps to the following logic, all flows are successfully working and documents are being created:

dataUriToBinary(replace(body('ParseJSON')?['FieldNameHere'], 'application/octet-stream', 'image/png'))

View solution in original post

Mari
Microsoft
Microsoft

Thanks for sharing your findings!

Helpful resources

Announcements
PA 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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (1,927)