Enticing visitors to your website is a significant challenge. To tempt visitors to engage with your site and complete a form is a much greater task. To win visitors over you must provide strong benefits to do so.
This article follows on from the previous article (Powerful Website Forms Using Microsoft Forms, Lists and Power Automate). In this article you will learn how to add a name and email text input to a form. I will show you how to amend your 'MS Power Automate Flow' to capture name and email.
Then forward the data to SharePoint Online list and add another Power Automate to send an email.
Microsoft Form add ‘Name’ and ‘Email’ input
Setup Time: 10 minutes
Setup Overview: These setup instructions walk through the steps required. To add a ‘Microsoft Form', ‘Name’ and ‘Email’ question. The lab exercise for PAF365: Power Automate Bootcamp
The first step is to open your ‘Form.’
Click the question above location you want to add ‘Name.’
Click the ‘+ Add new’ button.
You should see the below image. Click ‘Text.’
Type what you wish for example ‘Your first name’ or ‘Full name.’
Click the ‘+ Add new’ button.
You should see the below image. Click ‘Text.’
Type what you wish for example ‘Add your email address to download a free tutorial’ for question. For subtitle 'Powerful Website Forms Using Microsoft Forms, Lists and Power Automate.'
Return to your form embed webpage. You need to generate test data. Answer your form questions. Then return to your ‘MS Form’ app.
Click the ‘Response’ (1) tab then click ‘Open in Excel’ (2) to download the workbook.
Open ‘Excel’ download. You should see your newly added data inputs.
Your next step is to create a SharePoint list. Open Microsoft lists and click ‘+ New List.’
In the ‘Create List’ pop up click ‘From Excel.’
Click the ‘Upload file’ button and navigate to where you stored your Excel Workbook and click next.
Complete the next pop-up. Name the list, give your list a description, select an icon colour and icon and specify where the list is to be created and stored. In most cases the default ‘My lists’ and click create.
All being well you should see something like the below image.
Note: Your list may have fewer entries. This list is required to build a Power Automate Flow.
If you are experiencing any challenges with the above setup, please read the previous article. ‘Powerful Website Forms Using Microsoft Forms, Lists and Power Automate’ some steps above assume you have read and implemented the previous blog post.
Build a Flow
Setup Time: 30 minutesSetup Overview: These setup instructions walk through the steps required. Using a SharePoint Online List to develop a Flow to send a thank you email for submitting an online form with attachment. The lab exercise for PAF365: Power Automate Bootcamp
Now you have a SharePoint Online list click the Automate menu option and select ‘Create a flow.’
From the popup choose ‘Send a customised email when a new SharePoint list item is added.’
Power Automate opens. If you do not see green ticks indicating, you have granted permissions to services. You need to grant permissions by clicking the sign in links see below. Next click Create Flow.
A new window opens. Click ‘Edit.’
The next step window opens.
The above ‘Flow’ will grab new visitor form list submission data and with a few amends create a thank you email. The 'Flow' email will attach a OneDrive tutorial file. Then attach itself to the email before sending the email to the submitter of the completed form.
First, we need to step back a bit. We need to edit the ‘Flow’ you created in the first article. Remember you added two new questions. ‘Name’ and ‘Email.’
Open a second browser tab and open ‘Power Automate’ and select ‘My Flows’.
Select the ‘Flow’ you previously configured for the first article.
Within ‘Apply to each’ click to expand the ‘Create item.’
Hopefully, you should see the below. Add ‘Name’ and ‘Email’ dynamic content.
Note: ‘First Name’ at the bottom you need not bother adding dynamic content for this given you may have added ‘Your first name’ to ‘Name’ (below ‘Email’).
Note: ‘Power Automate’ does not like ‘Choice’ or ‘Rating’ questions. There is a work around. While the method is annoying it is relatively easy to implement.
You might find when you attempt to add the dynamic content to such questions the option to do so isn’t available. Yet when adding dynamic content to the previous question the option was listed.
There is a workaround. Assuming you have successfully ran the flow return to the flow history window. Click to open the successful run.
You should see the below.
Expand ‘Apply to each’, expand ‘Get response details.’ Under outputs scroll down to the question you have issues with.
Place your mouse cursor in the ‘Outputs’ body. Press the ‘Ctrl’ and ‘A’ key to select all. Then release the ‘A’ key while still holding down the ‘Ctrl’ press the ‘C’ key to copy.
Open ‘Note Pad’ or ‘Note Pad ++’ and place your mouse cursor in note pad and press ‘Ctrl’ and ‘V’ keys to place the copied text.
Notice I have added an expression.
Click the ‘Edit’ top right to edit your ‘Flow.’
Select the question Flow fails to allow you to add dynamic content. In my case question 5, ‘How likely are you to recommend this event to a friend or colleague?’ To add the ‘Expression’ place your mouse cursor in the box you need to add the content.
Then select the tab on the right ‘Expression’ see image below.
You will need to add
outputs('Get_reponse_details')?['body/add whatever code you identified here’]
Note: The code is unique so you cannot copy my example below.
You should see ‘Outputs.’ When you run ‘Flow’ you will probably see ‘Outputs’ changed to a form dynamic content.
Tip: If you experience issues amending your ‘Flow’ I suggest you create a new ‘Flow.’ So much easier than trying to find the error. You do not need the stress.
Return to the ‘Flow’ you created to send an email when a visitor to your website fills in your form. Delete ‘Get my profile.’
Click the ‘+’ sign below ‘When a new item is created.’ Click ‘Add an action.’
In the search box type ‘OneDrive’ (1) and click ‘OneDrive’ icon (2). Scroll down to select ‘Get file Metadata.’
Next add OneDrive ‘The unique identify of the file.’ Click the folder. In the submenu click the chevon and navigate to the OneDrive file you want to attach to your email.
Note: You could choose another online storage for example OneDrive for business, Dropbox.
Next move your mouse cursor below ‘Get file metadata’ to reveal the ‘+ Add action’ and click. In the ‘Choose and action’ search box type ‘Initialise variable’ (1) and select ‘Initialise variable’ (2).
Name your variable for example ‘FormsTutorial.’ For ‘Type’ in the drop down select ‘Array.’ For ‘Value’ leave as is.
Click the ‘+ Add action’ below ‘Initialise variable’ and in the search box type ‘OneDrive.’ Click the ‘OneDrive’ icon. Scroll down, to select ‘Get File Content.’
In the ‘Get file content’ click the folder to navigate to the ‘OneDrive’ folder and select the file you wish to attach to the email.
Your next step is to formulate your email. Click to expand ‘Send Email.’ To do this click the ‘Add dynamic content’ plus sign and scroll down and select ‘Email.’
For subject add ‘File name with extension.’
For body </> will need formulate our email text and this needs to be in html. You can use any html editor. If you do have one you could use Outlook. Send an email to yourself using the text you intend. Send that email. When it arrives open the email and right click to select ‘view source.’
Another method is to open the email. From the menu select ‘Message’ in the ribbon ‘Move’ section click ‘Actions’ select ‘Other Actions’ and click ‘View source.’
Both methods are unsatisfactory. The issue being by default additional code is added see example below.
While you could copy and paste the above code example into your ‘Flow’ and it would work. However, you might experience performance issues.
You could download ‘Microsoft Expressions Web’ (free) sadly only available these days through third party sites . Until recently you could download from Microsoft site.
Using ‘Microsoft Expressions Web’ you can create an ‘HTML’ page, type your copy as you would any other text editor. Html is automatically generated. Copy the ‘HTML’ and paste into your ‘Flow’ see below.
Next click ‘Advanced options’ drop down (see above image). Your email attachment needs to be added.
Place your mouse cursor in the ‘Attachments Name – 1 box.’ From the popup select ‘Name.’
Place your mouse cursor in ‘Attachments Content –‘ from the side menu choose ‘File Content’.
Save your ‘Flow.’
Check ‘Flow checker’ has passed your flow.
Finally return to your webpage with the form. Fill in the form and submit.
Check your SharePoint online ‘ My List’ and the data should be there.
Return to your ‘Flow.’ All being well your email ‘Flow’ was a great success.
Check your email.
If things did not quite work for you. Re-read this article. As you do check your implementation as your read. At the time of publishing both articles were tested by third parties and found to be correct.
Hopefully, you have learnt what you set out to achieve.
Thank you for reading this article.
Note: It is feasible to have just a single ‘Flow’. Breaking the flow into two keeps the learning process simple and hopefully ensures everyone can follow along and if necessary, debug. If there is a demand, I publish a tutorial illustrating a single flow for this process.