cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seussiii
Advocate I
Advocate I

Teams adaptive card - hiding blank or "0" fields

I'm in a pickle and could use some guidance. Hopefully this is the right place. 

 

I have an order form (using Microsoft forms), that includes ~5-6 products. Once filled out it pushes the data to a SP list and then onto an adaptive card in a teams channel for someone to work. I'd like to limit the fields on the card by only showing products that the customer is ordering. Many times its 1-2 of the 6 products with a Qty for each. How would I go about managing that?

 

It could be as simple as displaying text in a text block. I see a field in designer called "Only show when" but have no idea how that would be formatted or how to go about conditioning that based on the data column in sp? Thoughts?

 

image.png

1 ACCEPTED SOLUTION

Accepted Solutions

Hi again!

So I just modeled your SP item as an object variable called myOrderObject... we can work on the mapping from your SP item to this variable by means of a Select action block later

Flow_iterateTextBlock.png

Now I need two more variables:

-myOrderArray maps source object to a format we can iterate through. THe expression I'va assigned as its input is the following:

createArray(setProperty(setProperty(json('{}'),'ProductName','Product1'),'Quantity',variables('myOrderObject')?['Product1']),setProperty(setProperty(json('{}'),'ProductName','Product2'),'Quantity',variables('myOrderObject')?['Product2']),setProperty(setProperty(json('{}'),'ProductName','Product3'),'Quantity',variables('myOrderObject')?['Product3']),setProperty(setProperty(json('{}'),'ProductName','Product4'),'Quantity',variables('myOrderObject')?['Product4']))

-myOrderTextBlockArray will finally store the dynamic TextBlock structure

 

 

Now we have everything set for the iteration via an Apply to Each action block:

Flow_iterateTextBlock_2.png

 

The expression I assigned as 'Append to array' input is the following:

setProperty(setProperty(setProperty(json('{}'),'type','TextBlock'),'spacing', 'None'),'text',concat(item()?['ProductName'],': ',item()?['Quantity']))

 

Please note I add a Dummy Compose action block after the Apply to ech and assign as its input the variable 'myOrderTextBlockArray'. The reason is, If you implement this logic, execute the flow and inspect 'Compose 3' output you will see the content of this variable:

[
  {
    "type": "TextBlock",
    "wrap": true,
    "size": "Medium",
    "text": "Product1: 3 units"
  },
  {
    "type": "TextBlock",
    "wrap": true,
    "size": "Medium",
    "text": "Product4: 2 units"
  }
]

 

And we just need to add 'myOrderTextBlockArray' variable to the Adaptive Card JSON. I just implemented this dummy Adaptive Card

 

Flow_iterateTextBlock_3.png

 

If you need further assigtance pleas let us know

 

 

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

View solution in original post

9 REPLIES 9
efialttes
Community Champion
Community Champion

Hi!
Do you plan to display each product as a text block?
Thanx!

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

I could. I was thinking that's the easiest way. The rep just needs to know which product types and a qty for each. After that I will have a separate drop down selecting the pricing.

 

I've managed to figure out how to make all that work correctly but i'm just trying to figure out how to hide 0's or blanks so that each card doesnt have every product listed when they only ordered 1-2 of the product types for example. Hope that makes sense.

Hi again
And the zeros/blanks are currently stored in a SP list item right? So in your SP list do you have one column per product quantity requested? If so, is this column of type number?
Thanx!

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

yup! 🙂

Hi again

Let's assume you have 4 different products... current order request 3 Product#1 units and 2 Product#4 units

INside your adaptive card, is it valid according to your requirements to represent the text blocks inside a Container inside your JSON?

AS in this example

 

{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Product#1 Quantity: 3",
"wrap": true,
"size": "Medium"
},

{
"type": "TextBlock",
"text": "Product#4 Quantity: 2",
"wrap": true,
"size": "Medium"
}
]
},

 

 

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

I currently have it formatted like so

 

"type""TextBlock",
"text""Product 1: xxx",
"spacing""None"
 

xxx is filler for the QTY referenced in SP. Once I get the card designed I'll copy json into PA and add the dynamic references to SP. 

 

Edit: Currently they are not placed inside of a container. I could though I suppose? I haven't used containers much

No problema. Give me some minutes, working on it

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

Hi again!

So I just modeled your SP item as an object variable called myOrderObject... we can work on the mapping from your SP item to this variable by means of a Select action block later

Flow_iterateTextBlock.png

Now I need two more variables:

-myOrderArray maps source object to a format we can iterate through. THe expression I'va assigned as its input is the following:

createArray(setProperty(setProperty(json('{}'),'ProductName','Product1'),'Quantity',variables('myOrderObject')?['Product1']),setProperty(setProperty(json('{}'),'ProductName','Product2'),'Quantity',variables('myOrderObject')?['Product2']),setProperty(setProperty(json('{}'),'ProductName','Product3'),'Quantity',variables('myOrderObject')?['Product3']),setProperty(setProperty(json('{}'),'ProductName','Product4'),'Quantity',variables('myOrderObject')?['Product4']))

-myOrderTextBlockArray will finally store the dynamic TextBlock structure

 

 

Now we have everything set for the iteration via an Apply to Each action block:

Flow_iterateTextBlock_2.png

 

The expression I assigned as 'Append to array' input is the following:

setProperty(setProperty(setProperty(json('{}'),'type','TextBlock'),'spacing', 'None'),'text',concat(item()?['ProductName'],': ',item()?['Quantity']))

 

Please note I add a Dummy Compose action block after the Apply to ech and assign as its input the variable 'myOrderTextBlockArray'. The reason is, If you implement this logic, execute the flow and inspect 'Compose 3' output you will see the content of this variable:

[
  {
    "type": "TextBlock",
    "wrap": true,
    "size": "Medium",
    "text": "Product1: 3 units"
  },
  {
    "type": "TextBlock",
    "wrap": true,
    "size": "Medium",
    "text": "Product4: 2 units"
  }
]

 

And we just need to add 'myOrderTextBlockArray' variable to the Adaptive Card JSON. I just implemented this dummy Adaptive Card

 

Flow_iterateTextBlock_3.png

 

If you need further assigtance pleas let us know

 

 

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

oh wow. Much appreciation for diving into this, @efialttes . I didn't think it would be so involved. 

 

I'll have to get into it tomorrow morning but I appreciate your hard work and will follow up with a reply

Helpful resources

Announcements

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (5,908)