cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vaibhavtandon87
Helper IV
Helper IV

Post adaptive card in teams and update the response in List

Dear community,

 

I am trying to  build a flow that will:

 

1) look for items in List that are overdue ( this is built and working fine)

2) Send adaptive card for the overdue item to the user with 2 options - Closed/Open and submit button to capture response.

3) Update the list with the captured response from the user.

 

Have tried few different options but getting different errors and not able to make it work.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@vaibhavtandon87  , you can configure the flow as follows:

 

1. Use Get Items action to retrieve items from SharePoint list

2. Add apply to each action to loop through the items, also go to settings of this action and turn on the Concurrency Control property of apply to each action

3. In the apply to each action add actions as follows:

3.1 Add compose action and put below json for your adaptive card, update the duedate and created by fields in json as per your SharePoint list columns.

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "speak": "<s>Overdue Item</s>",
    "body": [
        {
            "type": "TextBlock",
            "text": "Overdue Item",
            "size": "Large",
            "weight": "Bolder",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Due Date: @{items('Apply_to_each_2')?['DueDate']}",
            "isSubtle": true,
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Created By: @{items('Apply_to_each_2')?['Author/DisplayName']}",
            "isSubtle": true,
            "spacing": "None",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Status",
            "wrap": true
        },
        {
            "type": "Input.ChoiceSet",
            "id": "status",
            "value": "5",
            "choices": [
                {
                    "title": "Open",
                    "value": "Open"
                },
                {
                    "title": "Closed",
                    "value": "Closed"
                }
            ],
          "placeholder": "Open"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit"
        }
    ]
}

3.2 Then add Post adaptive card to Teams Channel and wait for response action and configure it as follows

3.3 Change name of action to "PostAdaptiveCardWaitForResponse" and configure other properties of action as per below screenshot

Screenshot 2021-01-04 181546.png

3.4 Then add Update Item action to update the status selected in your adaptive card in the SharePoint list item, in order to get the status value from adaptive card, use the below expression

body('PostAdaptiveCardWaitForResponse')['data']?['Status'] 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

9 REPLIES 9
annajhaveri
Super User
Super User

@vaibhavtandon87 , can you please share the error that you are getting, also as you are getting items from list, are you using apply to each to loop through items and sending adaptive card inside apply to each loop? 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri  thanks for your response!

 

Since it wasnt working I removed that I may not be able to provide the error. I created a new adaptive card( basic) and its working and gives a button to view all overdueitems but would still want to achieve the above with buttons available to update the sharepoint item directly from the adaptive card.

 

Also attaching the code and images of flow:

 

  {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Update from Sharepoint",
"spacing": "Medium",
"size": "Large",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "A new item was added to a list",
"size": "Medium",
"spacing": "None"
},
{
"type": "FactSet",
"facts": [
{
"title": "Created by",
"value": ""
},
{
"title": "Due date",
"value": "@{items('Apply_to_each')?['DateReported']}"
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "View list",
"url": "URL Name"
}
]
}
],
"version": "1.2",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}

 

Adaptive 1.png

Adaptive 2.png

 

@vaibhavtandon87 , do you want to show list of overdue items and 2 options (closed/Open) for each item in adaptive card and one submit button?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Yes in a way @annajhaveri if that is possible?

 

Else if there is separate notifications sent individually for each over due item( rather than list) I am ok with that also. So if there are 5 items overdue for a user I am ok if there are 5 different notifications sent. But if it can go in one then it will be icing on the cake.

@vaibhavtandon87  , you can configure the flow as follows:

 

1. Use Get Items action to retrieve items from SharePoint list

2. Add apply to each action to loop through the items, also go to settings of this action and turn on the Concurrency Control property of apply to each action

3. In the apply to each action add actions as follows:

3.1 Add compose action and put below json for your adaptive card, update the duedate and created by fields in json as per your SharePoint list columns.

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "speak": "<s>Overdue Item</s>",
    "body": [
        {
            "type": "TextBlock",
            "text": "Overdue Item",
            "size": "Large",
            "weight": "Bolder",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Due Date: @{items('Apply_to_each_2')?['DueDate']}",
            "isSubtle": true,
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Created By: @{items('Apply_to_each_2')?['Author/DisplayName']}",
            "isSubtle": true,
            "spacing": "None",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "Status",
            "wrap": true
        },
        {
            "type": "Input.ChoiceSet",
            "id": "status",
            "value": "5",
            "choices": [
                {
                    "title": "Open",
                    "value": "Open"
                },
                {
                    "title": "Closed",
                    "value": "Closed"
                }
            ],
          "placeholder": "Open"
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Submit"
        }
    ]
}

3.2 Then add Post adaptive card to Teams Channel and wait for response action and configure it as follows

3.3 Change name of action to "PostAdaptiveCardWaitForResponse" and configure other properties of action as per below screenshot

Screenshot 2021-01-04 181546.png

3.4 Then add Update Item action to update the status selected in your adaptive card in the SharePoint list item, in order to get the status value from adaptive card, use the below expression

body('PostAdaptiveCardWaitForResponse')['data']?['Status'] 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

Thanks @annajhaveri , thats super!

 

Struggling with the last step and not sure what I am missing and what to put in id and title columns. Getting the error as per below and sharing screenshot of what I have put in 'update items' step. 

 

Update item properties.png

Warning - error.png

  

 

Did you do step 3.3 from my instructions? You need to rename the action.

 

annajhaveri_0-1609770440265.png

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
vaibhavtandon87
Helper IV
Helper IV

Sorry @annajhaveri , missed that.

Made the change it works like a charm!

 

Thanks again!

@annajhaveri  quick check - if I dont select any option from drop down ( closed / open) and still press the submit button, it takes blank that as an input though the flow fails in the background as 'blank' is not accepted value and the List is not updated with blank value.

Any way to ensure that submit button only works when there is a valid value ( closed / open)?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,563)