cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LABORSAL
Advocate II
Advocate II

PowerAutomate Adaptive Cards + Teams + SharePoint List Read/Write

Hello!

 

I've been working on a small project to have a Flow read the contents of a SharePoint list and build a card based on a field (email of the person responsible) to get updates on a few other fields.

 

After some time digging around on how to build dynamic adaptive cards, I found the way to do it and get responses coming back.

 

The problem is that as I need to create a dynamic card the "ID" response has to change and as I need more than 1 answer, I append a letter to the beginning of the ID to differentiate each answer.

 

The result is an object(?) with this structure:

[
  {
    "M1": "True",
    "A1": "Variable Text1",
    "M2": "False",
    "A2": "Variable Text2"
  }
]

 

and if I append it to an array, I get this structure:

[
  {
    "M1": "False",
    "A1": "Variable Text1",
    "M2": "False",
    "A2": "Variable Text2",
  },
  {
    "M3": "True",
    "A3": "Variable Text3"
  }
]

 

As mentioned before, the ID of the SharePoint list is the number after the A or M in the key. Therefore, what I am trying to do to complete this action and being able to update the list is to:

1) Remove the "M" and "A" from the key

2) Group the values based on the remainder of the key (so for these examples, 1 / 2 / 3) and add the ID field.

Something like:

[
  {
    "ID":1
    "M":"False",
    "A":"Variable Text1"
  },
  {
    "ID":2
    "M":"False",
    "A":"Variable Text2"
  },
  {
    "ID":3
    "M":"True",
    "A":"Variable Text3"
  }
]

 

1 ACCEPTED SOLUTION

Accepted Solutions

Sample Input:

 

DamoBird365_1-1619075236183.png

 

Result of Union on First()

 

DamoBird365_2-1619075270332.png

 

Sample Output:

 

DamoBird365_0-1619075209017.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

View solution in original post

6 REPLIES 6

Hi @LABORSAL 

 

I've assumed that your two objects can be joined using my method, i.e. they come back to your Cloud Flow as seperate objects?

 

You can join them using Union and FirstExpression and this will create a neat single Array of Keys/Values.

 

Then if you create a range of answers as an array, in this case 1,2,3 you can pass this to a select and use the values 1,2,3 dynamically to build up a new array using select.

 

To see it in action, copy and paste the following into a new cloud flow:

 

HowToCopyPasteSolution.gif

 

{"id":"dcfa8fc7-d817-4111-91e8-a4bf-69cb2f1a","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365_Create_New_Array_from_Two_Objects_Using_Select","operationDefinition":{"type":"Scope","actions":{"Obj1":{"type":"Compose","inputs":[{"M1":"True","A1":"Variable Text1","M2":"False","A2":"Variable Text2"}],"runAfter":{}},"Obj2":{"type":"Compose","inputs":[{"M3":"True","A3":"Variable Text3"}],"runAfter":{"Obj1":["Succeeded"]}},"Union":{"type":"Compose","inputs":"@union(first(outputs('Obj1')),first(outputs('Obj2')))","runAfter":{"Obj2":["Succeeded"]}},"RangeArray":{"type":"Compose","inputs":"@range(1,3)","runAfter":{"Union":["Succeeded"]}},"SelectNewArray":{"type":"Select","inputs":{"from":"@outputs('RangeArray')","select":{"ID":"@item()","M":"@outputs('Union')?[concat('M',item())]","A":"@outputs('Union')?[concat('A',item())]"}},"runAfter":{"RangeArray":["Succeeded"]}}},"runAfter":{}}}

 

This is what the Cloud Flow looks like:

DamoBird365_0-1619075131672.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

Sample Input:

 

DamoBird365_1-1619075236183.png

 

Result of Union on First()

 

DamoBird365_2-1619075270332.png

 

Sample Output:

 

DamoBird365_0-1619075209017.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

Thanks for your reply @DamoBird365! What you suggest does pretty much all of the work I believe, to make it work however I have to transform the IDs from SharePoint instead of expanding a range, in the given example it was from 1 to 3 so the range you suggested worked, however in practice it'd be working with variable numbers and likely not in order.

 

I've been trying to figure out how to do it but the best I can do is pull them and use a select which leaves them like this (very different to the range your process needs).

 

Do you know a way to transform this into a range of integers as your process requires? 

 

[
  {
    "ID": 1
  },
  {
    "ID": 2
  },
  {
    "ID": 3
  },
  {
    "ID": 5
  }
]

 

@LABORSAL 

 

I’m away from PC but think you can do a select using the advanced editor. Source is your array, the data is item()?[‘id’].

 

Should give you an array of numbers.

 

Damien

Hello again @DamoBird365 ,

 

I tried your idea but couldn't make it work, however with an apply to each appending the ID as an int to an array I build the missing range array with only the needed numbers

 

I now came across another issue where changing your code seems to break how it works, but I don't exactly understand how.

 

After all the process I have my 2 arrays (answers and IDs)

 

This is the answers array (to simulate the scenario you might notice M3 and A3 are missing, this is already coming from the adaptive card)

LABORSAL_1-1619450894401.png

 

This is the ID array which has the same 1/2/4/5 IDs in it from the list

LABORSAL_2-1619451004666.png

However, when I try to build the select with conditions it gives me an error

InvalidTemplate. The execution of template action 'SelectNewArray' failed: The evaluation of 'query' action 'where' expression '{ "ID": "@int(item())", "M": "@variables('AnswersArray')?[concat('M', item())]", "A": "@variables('AnswersArray')?[concat('A', item())]" }' failed: 'The template language expression 'variables('AnswersArray')?[concat('M', item())]' cannot be evaluated because property 'M1' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.
 

 

This is the block code:

{
    "inputs": {
        "from": "@variables('IDArray')",
        "select": {
            "ID": "@int(item())",
            "M": "@variables('AnswersArray')?[concat('M', item())]",
            "A": "@variables('AnswersArray')?[concat('A', item())]"
        }
    }
}

 

I made some changes on the original one so it points to the IDArray (instead of built range) and instead of the union output for M and A it points to the AnswersArray. I don't understand the error as it seems the error is it can't select M1 but it's there.

 

Any advice you could share? 😀

Thanks!

Hello! I kept trying new things and instead of using the built array I shared I placed the body of the adaptive card and it seems to work! (likely some kind of data type issue)

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

Users online (1,554)