web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / setProperty for comple...
Power Automate
Unanswered

setProperty for complex JSON objects

(0) ShareShare
ReportReport
Posted on by 4
Hi,
 
What is the best way to manipulate complex JSON objects?
 
For example I want to update an existing, already posted adaptive card and I want to toggle the visibility of a button based on some action.. I can retrieve the adaptive card using a GetMessageDetails action, but then updating a deeply nested property of the Adaptive Card  is almost impossible to do. The SetProperty function does not allow to provide a path. Instead it offers an overloaded method where you can specific the parent object, but even that I am not able to get that properly working.
 
Below is an oversimplification of the adaptive card I have.
 
How can I easily update the isEnabled property using JSON manipulation where the property is nested inside multiple arrays? 
 
 
{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "text test stestes"
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "width": "stretch"
                }
            ]
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "Acknowledge",
					"isEnabled": true,
                    "data": {
                        "action": "acknowledge",
                        "uid": "uniqueId"
                    }
                },
                {
                    "type": "Action.Submit",
                    "title": "Resolve",
                    "isEnabled": false,
                    "data": {
                        "action": "resolve",
                        "uid": "uniqueId"
                    }
                },
                {
                    "type": "Action.Submit",
                    "title": "Close",
                    "isEnabled": false,
                    "data": {
                        "action": "close",
                        "uid": "uniqueId"
                    }
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.6"
}
 
 
 
Categories:
I have the same question (0)
  • SaiRT14 Profile Picture
    1,990 Super User 2025 Season 2 on at
    pls try the following: - javascript arrays can help.
     
    const adaptiveCard = {
      "type": "AdaptiveCard",
      "body": [
        {
          "type": "TextBlock",
          "size": "Medium",
          "weight": "Bolder",
          "text": "text test stestes"
        },
        {
          "type": "ColumnSet",
          "columns": [
            { "type": "Column", "width": "auto" },
            { "type": "Column", "width": "stretch" }
          ]
        },
        {
          "type": "ActionSet",
          "actions": [
            {
              "type": "Action.Submit",
              "title": "Acknowledge",
              "isEnabled": true,
              "data": { "action": "acknowledge", "uid": "uniqueId" }
            },
            {
              "type": "Action.Submit",
              "title": "Resolve",
              "isEnabled": false,
              "data": { "action": "resolve", "uid": "uniqueId" }
            },
            {
              "type": "Action.Submit",
              "title": "Close",
              "isEnabled": false,
              "data": { "action": "close", "uid": "uniqueId" }
            }
          ]
        }
      ],
      "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
      "version": "1.6"
    };
    // Function to update `isEnabled` for a specific action
    function updateIsEnabled(card, actionTitle, newState) {
      const actionSet = card.body.find(item => item.type === "ActionSet");
      if (actionSet) {
        const action = actionSet.actions.find(a => a.title === actionTitle);
        if (action) {
          action.isEnabled = newState;
        }
      }
    }
    // Example: Toggle "Acknowledge" button to disabled
    updateIsEnabled(adaptiveCard, "Acknowledge", false);
    console.log(JSON.stringify(adaptiveCard, null, 2));
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard