The world of PowerApps can be new and exciting, not to
mention completely frustrating! A lot of my frustrations come from my lack of
knowledge of the product but there are times when it’s not that, but an issue
with the Office 365 platform itself.
This brings me to my issue I was having when embedding PowerApps onto an Office 365 modern SharePoint page. I had saved and published my form, and all seemed well. It displayed perfectly or me, all controls worked, etc. I had someone on my team test and suddenly, something was amiss.
My tester said that they were being asked for credentials.
But why? Why would I ever need to provide my login information again after I
have already logged in to 365? If you don’t know what I’m talking about or
haven’t been fortunate yet to see this screen, this is what it will look like:
This post mentions that if you receive the connection
permission sign in pop up, that it is possible to bypass it by running the following
PowerShell command bout having to run a PowerShell command:
Now, don’t do what I did and run this command expecting
everything to work all nice and stuff. There are a number of steps you need to
follow before you can even run this command. That being said…….. Let’s do
If you notice, there is a GUID used to identify the PowerApp. The easiest way to get the App ID (GUID) is to login to the PowerApps Admin Center. Once there, find the specific PowerApp that you are working with and click on it to see the details. At the bottom of the screen you should see the App ID. Copy the GUID next to that and place next to –AppName in your script.
You can also use this PowerShell command, Get-AdminPowerApp, but for me this is a slower process because I’m having to look through the many line items. I’ve always been more of a GUI type user, so really it’s just a preference.
Once run, you will see the following output on your screen:
Hello all! It’s been at least two years since I have posted something technical on my Salty Blog, pathetic right?. This how-to in my opinion was too good not to share as I believe that it will help others that are facing/have faced this issue.
The ability to email attachments from a list is one of those pain points that I seem to face all of the time. This documentation will take you through the process of setting up a new Flow that will grab all attachments for a single list item and will then email those attachments back out to the intended target.
Before I begin, let me preface this post stating that I did not come up with this. I found a couple of posts and podcasts but I wanted to compile this working version into one blog post.
I was searching for an answer on this issue late last year and attending one of Laura Roger’s weekly Power Hours and she presented on this. Here is a link to that original broadcast: SharePoint Power Hour: Flow Attachments & Files . If you follow the recording to the end, you will notice that Flow was not behaving properly. Well, I could not get it to work either and after a month of trying different things, I gave up.
A couple of months later I, I received an update from Microsoft’s Blog on Flow which is named Flow of the Week. This particular flow caught my eye: Send multiple attachments on a single email. I couldn’t believe it! This was exactly what the doctor ordered or at least I thought it was. I had setup the Flow as explained in the blog post but when I would run the Flow, I would receive the following message: “No input parameters provided. Please provide required input parameters ‘To’, ‘Subject’ and ‘Body'”
You’ve got to be kidding me!!!!!! Why is this not working for me?!?!?!?! I just want to send an email with the list attachments!!!!! I need this to work!!!!!
Ok, calm down……… After a couple of weeks had passed and after I tried all that I could think of to get around this error, I went back to that Microsoft blog post and noticed a comment by Vytenis Jazbutis. He explains how he was able to get around this with a “fix” for the issue of the final “send email” step. It doesn’t like and doesn’t want to add the full “file content” file from the array as an email attachment. What it wants instead is the .$content property within the file contained in the array.
I have decided to recreate the blog post showing the new way of grabbing the attachments with Vytenis’s fix. Once again, all props goes to Laura, Sunay and Vytenis of this.
With that being said, let’s dive into this and build out this Flow!
Add a new “SharePoint – Create item” trigger and select the correct SharePoint Site and List. *** Please ensure that you already have SP List created that allows storing multiple attachments on the items in it.
Add a new “Schedule – Delay” step *** I added this additional “Delay Step” because I was getting inconsistent results. Sometimes the trigger would fire too early and would send a blank email without grabbing the attachments. By adding this 30 second delay, it will give Flow the ability to run each step in the process before sending the email. You may not need this in your environment but in my experience even with SharePoint Designer workflows, I have to add these more often than not.
Add a new “SharePoint – Get attachments” step
*** This step will be grab all of the attachments added to the newly created list item. Use the Site name and List name from the previous step. We want to then pipe the output “ID” from the trigger, to the input ‘ID’ field.
Add a new “Variables – Initialize variable” step *** This variable will be used to store all of the attachments in a single array.
Add an “Apply to each” step.
Click inside of the *Select an output box and click the “Body” output from the “Get attachments” section
Click the “Add an action” button and select “SharePoint – Get attachment content”
For the ID field, select the “ID” output from the “When an item is created” trigger section
For the File Identifier field, select the “Id” output from the “Get attachments” section
Click the “Add an action” and select “Variables – Append to array variable”
For the Name field, select “attachmentArray” from the dropdown. (this was created in step 4)
For the Value field, type in the following JSON statement:
For “ContentBytes”, click between the : and , and then click on the “Expression” output
Type in the following expression: body(‘Get_attachment_content’).$content and click the ‘OK’ button
*** “Get_attachment_content” is the name of the step created in 5b. Don’t forget the underscores for spaces.
For “Name”, click between the ” and : and select the “DisplayName” output from the “Get attachments” section
*** See “Note” below on additional details about the “ContentBytes” parameter The completed step should look like the one seen here
Add a new “Office 365 Outlook – Send an email” step
*** Note: Use whatever mail client that you have setup to run this step.
Fill in all of the required fields (if applicable to your mail client).
*** I have a list value that I am using to populate my “To” field.
Click the “T” icon next to the Attachments Name field. This switch will change the attachments control from “Detail inputs for array item” to “Input the entire array”
For the Attachments field, select “attachmentArray” from the “Variables” section.
The completed Flow should look like the following:
Save your Flow, then go to your list and create a new list item with attachment(s) to test. Remember to be patient if you put in the delay step. You should receive an email with the attachment(s) that you added to the list item.
This solves a lot of issues that I was having and I hope that it will help you in some way.