cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Annc1
Regular Visitor

Trying to format a text box using Forms

Hello. Please bear with me as I am new to this. 😞

I've created a form in MS Forms which is working just fine. There are some conditional questions in the form which also are working. I have 2 questions.

  1. I need to email the responses to 3 email addresses and have that working in Power Automate as well.  However, a couple of the answers in the form are text boxes such as a name and address.  I am trying to figure out how to format the answers coming in the email.  I've tried all I know to try and I've failed, then I found this forum!

So, I want the answer to be sent looking like this:

Bob Smith

123 Broadway Walk

Marion, IL 62592

But, it comes like this: Bob Smith 123 Broadway Walk Marion IL 62592

     2.  Using the dynamic content I'm trying to get the answers to 2 questions side by side but can't get the spacing right. In the form it's conditional, Is there an asset number?  If they check yes, a box appears to enter the asset #, if no it moves to the next question. Adding the questions as dynamic content in Power Automate under each other made the sent email too long to print on one page.  So I put the 2 questions side by side in Power Automate. This is how I would like it to come out:

Asset#?        Number

Yes               123654

But it comes out: Asset#?        Number

                           Yes   123564

How do I format it?  Thank you so much for reading this and for any help you can offer. 

Ann

12 REPLIES 12

Can you add a screenshot of the send email step and where you have the dynamic content? 

 

You will probably have to do some manual html formatting for your email to align things correctly. It is not incredibly difficult, but can take some trail and error to see how it shows in the final email.

 

You could also make HTML table for some of the responses and then put the HTML table in your email.

I hope this is what you mean? The dynamic content is what I've put into each section.

Some of the questions in the form are conditional, like the one, "Ship to Site/Base or home." The actual form has 'other' as a choice also and if that is selected the box for the other address come up.  I can't get the address to be on separate lines which is where I'm stuck with this.

Thanks for replying so quickly. Sorry I'm such a newbie at this.

Ann

Thanks for showing the screenshot, it is very helpful the more people can see on here the more they can work with it.

 

Ok, so I’m going to start with the easy(ish) problem to fix which would be your number 2. That is dealing with the 2 conditional sections Asset Inventory Numbers and the Urgent Shipment.

Those could be solved by making HTML tables in steps before the email and then inserting them into the email. I can show an example, but first I need to address your first issue.

 

For your number 1 dealing with the address format will be Extremely difficult simply because you have the address all put together in a single dynamic content and there is no real way to split up the value consistently because there’s not a good reference separator.

 

For example, if I had a form question that was “Put in your age and favorite color” and people responded with “20 blue” or “30 green”, we could split the value based on the space. Or we could have a fancy split expression that splits the value based on numbers and letters.

With the address response on a single line, there is not going to be a good way to split up the value because it has names, variable amounts of spaces, and numbers which they could write in the value in multiple different ways.

 

I just saw someone post this issue about splitting. You can see how much work they have to do and their values have commas to help with the format AND they know the text they want. An address has barely anything that could be used to split, Especially when the user can free text fill out the field.

https://powerusers.microsoft.com/t5/Building-Flows/Removing-extra-text/m-p/2037895#M225163 

 

So I said all of that to ask if you can just change your address questions in the form into separate questions? I know it will be less clean adding more fields into your form, but it will be MUCH easier to deal with if they have a separate form response value for each Name, Street Address, State, Zipcode. It’s why every website you buy something makes you fill out the separate fields.

I guess you could have just Name, Street Address, and CityStateZipcode so that’s only 3 fields. But I would go ahead an break out the state and zip because you could end up using it for better automation later.

 

Can you change the address questions into separate fields of your form?

I just did some quick form testing, and I think you could make good use of the Section function in MS Forms. So you could have different sections Person Info, Item Details, Shipping From, Destination Address, Other Notes.

 

The benefit of the different sections is that is breaks the form into separate pages. They have to click Next to move to the next section. This will make the amount of fields appear smaller since it's not on one page with dozens of fields to complete.

 

Maybe that is something to utilize when making different fields?

Oh I get it now! It's sort of like doing a mail merge from an Excel file, first name, last name etc have to be in different columns.

So, yes, I can put more fields in for the address.  I guess I'll have to do that for the other text box I have where I ask them to list the items to be shipped. There's usually more than one item and it will be so much easier to read the response if the items are on different lines.

I'll play around with that tomorrow. 

If you could show me an eg of the html tables I'd appreciate it. I've not used html before to do something like this. 

I've just read your second email about sections. I don't know much about sections either! So much to learn, but I'm a willing student! 🙂  At the moment I have drop downs for shipping from and shipping to. They seem to be ok. I'm not sure there is enough of a form to warrant sections? I've made it conditional in places so only the necessary questions are asked.  The users may consider having to hit next all the time is a pain. I see the functionality in a larger form but this is tiny by comparison to what most folk are doing here.

I really appreciate you taking the time to help with this and to do some testing.  As I learn I expect to progress onto larger processes and challenges. 

So thanks again and I'll work on the html after seeing your example.

Ann

Good morning.

I've changed the fields as you suggested. I've taken a screenshot of the dynamic content. 

Sometimes there may be more than one asset number, eg if there are two laptops being shipped. I'm wondering if it's possible to to create a table using the fields to make it clear which item has which asset number? (Please see below.) I don't know if it's possible to do this in Forms? If not I could add a field for 2 asset numbers, 'Item #1 Asset #' then another field 'Item #2 Asset #"

What do you think? 

Thanks again.

Item NumberAsset Number
  
  

Ok, I see your most recent message about formatting line breaks in tables for item Ids. That will be potentially possible, but first I want to get the major formatting done. If you can get the things done below, it will make dealing with individual tables easier. So I’m not addressing that issue in this response.

 

Introduction Note:

For Starters, I want to say that dealing with HTML format of emails in Power Automate can be tedious and you can spend hours trying to test and format perfect emails.

What is happening in the email step is that you put what you want in the email body, then when it is sent, all of that is converted to HTML. So if you were a wizard or wanted to try, you could manually code in all of the information. What we are trying to do is cheat and plug things in and let the step handle the conversion to HTML.

 

The more you try to format and get things in place, the more you will start asking if this information is even necessary. You may even decide to change the questions you are asking to make the email easier.

(A possible example would be to have a branch question in the form about Urgent Shipment. If they click Yes, then it goes to next question that is “Deliver By Date” and select the date. If they click No, then it skips over the date question. Now you can logically say, “if there is a date, then it must have been selected Urgent” so I actually only need the Delivery By Date in my email and don’t really need to say if it was Yes or No in a table format.)

 

Example Flow Intro:

The flow I am showing below looks like a lot of things to do, but really it is just steps that are getting things in a format to be plugged into the email.

Note: I have renamed my steps. The first part of each step name is what it would be in power automate like “Initialize variable” “Compose” or “Append to array variable” and the rest is my name details. I also added letter numbers to show those things go together. So A1, A2, & A3 are all dealing with the Asset Inventory Number information.

 

Below is an image showing the flow steps overview:

Flow Steps OverviewFlow Steps Overview


Example Flow Steps Details:

When a new response is submitted – (obvious)

Get response details – (obvious)

 

Compose – CSS Code to Format the Color and Border of Tables

This step is a Compose that has had CSS table format code copy and pasted into it. I got the code from an example website https://www.tachytelic.net/2020/11/power-automate-style-html-table/ where they talk about formatting tables. I simply copy and pasted it into the Compose step. (I did delete the line of the code Width: 100%; because it was making the table the size of the email.)

 

This Compose output will be placed directly in front of each of the HTML tables in the email body. So when the flow runs, the format code will appear and apply to the table.

 

The code that is in the compose example is below:

<style>
Table {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #EEEEEE;
  border-collapse: collapse;
}
Table td, Table th {
  border: 1px solid #ddd;
  padding: 3px 3px;
}
Table th {
  font-size: 12px;
  font-weight: bold;
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #1C6EA4;
  color: white;
}
</style>

 

A1 Initialize variable – Array to hold AssetInventoryNumbers

This step is an Initialize Variable that is an Array. This array will be a container to hold the responses you want in the table. It should be empty in this step with only [] open and close square brackets. It will be filled in the next step.

 

A2 Append to array variable – Put in Asset Inventory Number Responses

This is an Append to array variable step. In this you are basically naming the column headers and values that will populate the HTML table. You have to be aware of the format in this container. It is an open curly bracket { then press enter for line break. Then double space and put the items in quotes. There is a comma between the first and second line, but not after the last line. Then a line break with close curly brackets.

Example Format of the Array Info Below:

{
  "Any Asset Inventory Numbers?": {FormResponseValue},
  "Asset Inventory Numbers": {FormResponseValue}
}

 

A3 Create HTML table – Asset Inventory Numbers

This is a Create HTML table step. You will put the variable array AssetInventoryArray in the From section and then use Automatic columns. It is just using your previous entries as column headers and values.

 

B1 Initialize variable – Array to hold UrgentShipmentInfo

Basically the same as previous step A1 with a different name to hold different info.

 

B2 Append to array variable – Put in Urgent Shipment Info

Basically the same as previous step A2 with different row names and values.

 

B3 Create HTML table – Urgent Shipment

Basically the same as previous step A3 except is uses the array variable UrgentShipmentArray as the From.

 

C1 Initialize variable – String Items to Ship Format Line Breaks

This is an Initialize variable step as a String. This step is used to format the Items received from the response. Since the response form allows for multiple line, this expects for the person to fill out the form and press enter/line break after each item they put in the response. (If they don’t put on separate lines, this will not work.)

 

There is an expression around the response value, and it is basically finding the line breaks in the response and replacing it with the correct line break code that can be read in the email as HTML format. So in the response value from the form, line breaks are coded as %0A. In the email format line breaks need to be coded as <br/>.

 

The expression is looking for every %0A and replacing it with <br/>

This variable will be used in the email body in place of the items response.

Expression below:

uriComponentToString(replace(uricomponent({FormResponse}),'%0A','<br/>'))

 

D1 Initialize variable – String that will be used as Horizontal Line

This is an Initialize variable step as a String. This step contains the CSS code that generates a horizontal line in an email.

You will put this variable in the email body whenever you want a horizontal line divider.

<hr style="border-width: 0; background: #000; color: #000">

 

Send an email (V2)

This is the send an email step. You basically plug in all of the items or responses that you want. You will need to test and see how it appears in the final email.

 

When it comes to the format of the tables. Just put the output of the Compose that had the CSS style directly in front of the HTML table output. This will apply the style to the table when it is sent.

 

FYI: Do not press the </> button above the body. That will convert it to HTML code and you won’t be able to get it back to normal. You’ll have to delete the step and start over. You can use the </> option, but it can be difficult if you haven’t done it before. You could save the flow and press </> just to see what it looks like. It will probably give you a better idea of what is going on.

 

Below I'm Inserting the Images of the example form I used:

Form Section 1Form Section 1Form Section 2Form Section 2Form Section 3Form Section 3

 

Below are images of each flow step:

Flow Detail Steps 1Flow Detail Steps 1Flow Detail Steps 2Flow Detail Steps 2Flow Detail Steps 3Flow Detail Steps 3Flow Detail Steps 4Flow Detail Steps 4Flow Detail Steps 5Flow Detail Steps 5

 

Below is an image of what the email looks like when it is recieived:

Email Result ViewEmail Result View

 

I hope this outline gets you going in the right direction. It can be difficult to format beautiful emails in Power Automate, but once you get the hang of it or look up examples it will get easier. 

 

Let me know how it works for you,

This is incredible, thank you so much! You have gone above and way beyond.

I've been too busy at work to implement the changes the last few days but I'll keep you posted and let you know when I have.

Thanks again.

Ann

Annc1
Regular Visitor

OK, I'm so so close!  In the screenshot I attached I only have the one outputs and I don't know why. I've followed everything you've done including A3 and B3 to create the HTML tables. Here's an image:

Annc1_0-1678404732326.png

But, as you can see from the attached file, only the one outputs is available. What have I done wrong?

Thanks.

Ann

Thanks for the screenshot, that was helpful.

 

It looks like you made a step "Filter array" and then renamed it 'B3 Create HTML table - Urgent Shipment' so that is why it is not working.

 

Create HTML Table vs Filter ArrayCreate HTML Table vs Filter Array

 

You need to find the step that is called "Create HTML table" and use that. I see that the color of the step and the symbols are the same, so that maybe causing the confusion.

Choose an operationChoose an operation

 

In my example flow, all of the step names have the default name of the step at the beginning after the order letter and number I added. 

 

Step Default NamesStep Default Names

 

Sorry for the confusion, renaming steps helps keep things organized and descriptive, but sometimes it makes things less obvious.

 

Change your steps to the correct operation and see how it works.

Annc1
Regular Visitor

OK, got that fixed and working. The tables are being created just fine.

But, "Items To Be Shipped" is not.  I've searched and searched all my entries in case I put a space or something but I can't see it. The first screenshot is what comes through to my email and as you can see the tables below are fine. (The address is also working.)

Screenshot 2023-03-10 162530.png

 

 Next shot is of C1 the "Items to Ship string."

Screenshot 2023-03-10 162640.png

After it was done I tested it from the Power Automate window and the flow worked but when I opened the Send an email it had changed to HTML. I could figure out what each line was but the Items to be shipped had changed some. 

Screenshot 2023-03-10 162807.png

 

I copied the string because it was cut off and this is it:

</u><u>uriComponentToString(replace(uricomponent({FormResponse}),'%0A','<br/>'))</u><u><br>

 

When I typed it in C1 I put in exactly what you said. Maybe it's supposed to change, I don't know. 

Before I sent another response I made sure I saved my changes in Power Automate and I closed my Forms window to refresh it.

I so hoped to be able to send you the response looking just as it should! But, not yet I suppose. 

It's probably something obvious I'm missing here, but I'm missing it!

Thanks again. 😞

You need to replace {FormResponse} with the dynamic content/form response that you want to put in that field.

 

The use of curly brackets {} is used in the instructions to show a like a place holder for that value. I didn't put the actual form response value because it is long character strings and it wouldn't match the numbers that are from your form response.

 

So you need to delete the brackets and the text - so completely remove {FormResponse} and instead put the items to be shipped value from the form.

 

In step C1 Initialize Variable my exact expression is:

uriComponentToString(replace(uricomponent(outputs('Get_response_details')?['body/r07b678f4d4964dbeaacef2dc7cb76f0f']),'%0A','<br/>'))

 

So in my expression the {FormResponse} is replaced by 

outputs('Get_response_details')?['body/r07b678f4d4964dbeaacef2dc7cb76f0f']
 
The actual form question is "Items to be shipped", but it shows as the character string above when put into an expression.
 
wskinnermctc_0-1678717423091.png

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages