Problem: Recently I have a requirement to upload recorded audio from powerapps to sharepoint.
Requirements seems to be straight forward if you have a basic knowledge of Powerapps and Microsoft flow isn’t it? But there is a catch (let’s see that in sometime :-))
Just for the completeness of this blog, I will reiterate certain Hows.
How to Record and listen the Audio in powerapps?
In powerapps we have a media control named MicroPhone to record the audio, and another media control named Audio to listen to the recorded audio.
Further on how to do that:
In the Microphone control (I named as MyMic) Onstop property collect the recorded audio as follows:
In the Audio Control Media property, place the collection which you have used to collect the recorded audio earlier as follows:
We now know how to record and listen the audio within powerapps. Now lets discuss the actual challenge on how to upload it to sharepoint.
We use Microsoft flow to upload to sharepoint however in my microsoft flow it looks straight forward to pass the audio as First(collInspectionAudio).URL to my sharepoint file content as shown below.
when I execute the Powerapps and hence my flow it is creating an audio file in my sharepoint, however its not playing. when I see the outcome of the Flow i found it strange because File content looks as below:
When I further drilldown into the problem by checking the datatypes in flowstudio. I realized that in Createfile action of Sharepoint connector expects Binary format whereas powerapps send its audio content in byte format.
So the only way to get around is accept Byte parameter from Powerapps and use it to upload file in sharepoint.
For that, I used Outlook connector to send an email. When I ask for attachment parameters in powerapps it can send in byte format.
Note: If you have a requirement to send email of the audio file along with uploading in sharepoint then that’s amazing. If you don’t have such emailing requirement then another slight hack is required.
Create a condition which never becomes true. (in my case 100 equals 200 which never becomes true ;-))
In the true section call Outlook connector and ask for parameters for Attachment Name and Attachment Content.
In the false section call Sharepoint Connector and create a file by using same parameters which we have in Step 2.
Final working Microsoft Flow looks like this:
For any doubts or questions, please contact me on firstname.lastname@example.org