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 / Copilot Studio / How to check for empty...
Copilot Studio
Suggested Answer

How to check for empty variables in adaptive cards?

(1) ShareShare
ReportReport
Posted on by 16

I paste JSON from adaptive card designer into my adaptive card in Copilot Studio. I then switch from JSON to Formula in order to use variables in the adaptive card like this.

My problem is that some variables might be empty. What should the syntax be to check for empty values in this case?

{
  type: "TableCell",
  items: [
      {
        type: "TextBlock",
        text: Topic.Record.Status,
        wrap: true
      }
   ]
}
Categories:
I have the same question (0)
  • Artur Stepniak Profile Picture
    1,539 Super User 2025 Season 2 on at
    Hello,
     
    you can use something like: If(IsBlank(Topic.Record.Status), what if blank, what if not blank).
     
    In the meantime - I've just opened a group related to Copilot stuff. Maybe you'd like to join? I plan for it to be the place, where we can help each other. Here's the link: https://community.powerplatform.com/usergroups/details/?groupid=dbc367c2-b7b7-ef11-b8e8-7c1e5259f813.
     
    In case of any other questions, let me know. If the answer helped you, mark it, so that others can benefit from it.
     
    Best regards,
     
    Artur Stepniak
  • PC-16121332-0 Profile Picture
    16 on at
    Thanks @Artur Stepniak, but that does not work. The function itself work but the syntax is not allowed.
     
    Should I use JSON or Formula mode for my adaptive card in Copilot Studio? Can you please update the code in my original question with a working code? I get a syntax error no matter what I do.
  • Suggested answer
    Artur Stepniak Profile Picture
    1,539 Super User 2025 Season 2 on at
    Hello,
     
    I've just created a sample card with an expression:
     
    {
      type: "AdaptiveCard",
      body: [
        {
          type: "TextBlock",
          size: "Medium",
          weight: "Bolder",
          text: "${title}"
        },
        {
          type: "ColumnSet",
          columns: [
            {
              type: "Column",
              items: [
                {
                  type: "Image",
                  style: "Person",
                  url: "${creator.profileImage}",
                  altText: "${creator.name}",
                  size: "Small"
                }
              ],
              width: "auto"
            },
            {
              type: "Column",
              items: [
                {
                  type: "TextBlock",
                  weight: "Bolder",
                  text: "${creator.name}",
                  wrap: true
                },
                {
                  type: "TextBlock",
                  spacing: "None",
                  text: $"Created {If(IsBlank(Topic.Var1), "IS BLANK", "TEST")}",
                  isSubtle: true,
                  wrap: true
                }
              ],
              width: "stretch"
            }
          ]
        },
        {
          type: "TextBlock",
          text: "${description}",
          wrap: true
        },
        {
          type: "FactSet",
          facts: [
            {
              '$data': "${properties}",
              title: "${key}:",
              value: "${value}"
            }
          ]
        }
      ],
      actions: [
        {
          type: "Action.ShowCard",
          title: "Set due date",
          card: {
            type: "AdaptiveCard",
            body: [
              {
                type: "Input.Date",
                id: "dueDate"
              },
              {
                type: "Input.Text",
                id: "comment",
                placeholder: "Add a comment",
                isMultiline: true
              }
            ],
            actions: [
              {
                type: "Action.Submit",
                title: "OK"
              }
            ],
            '$schema': "http://adaptivecards.io/schemas/adaptive-card.json"
          }
        },
        {
          type: "Action.OpenUrl",
          title: "View",
          url: "${viewUrl}"
        }
      ],
      '$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
      version: "1.3"
    }
     
    Here's the topic:
     
     
    You can use interpolated string in order to validate it properly: $"{}". I've shown an example above.
     
    In case of any other questions, let me know. If the answer helped you, mark it, so that others can benefit from it.
     
    Best regards,
     
    Artur Stepniak
  • Artur Stepniak Profile Picture
    1,539 Super User 2025 Season 2 on at
    And unfortunately I cannot update your code, because you've just sent a part of the card. :-)
  • Suggested answer
    PC-16121332-0 Profile Picture
    16 on at
    Thank you so very much! It worked great.
     
    How did you know the syntax? Is it in some documentation? Also, do you have any suggest on a work flow for this? I copy code from the adaptive cards designer,  paste as JSON in Copilot Studio, switch to Formula and then adjust (remove quotes from) the code where neded. It's kind of tedious.
     
    Thanks again. I really appreciate your help!
  • Suggested answer
    Artur Stepniak Profile Picture
    1,539 Super User 2025 Season 2 on at
    Hello,
     
    I've used interpolated string to achieve this, tried to find it in the language reference for Power Fx - it's a language used in PowerApps, which's also used in Copilot Studio - but without luck. Maybe you'll have better eye: https://learn.microsoft.com/en-us/power-platform/power-fx/overview. Nevertheless, it's the one with $"{}".
    I've done it the same way, I don't see any other option. You could use GPT to fill it for you, something like: Convert this adaptive card JSON to Power Fx formula. 
     
    In case of any other questions, let me know. If the answer helped you, mark it, so that others can benefit from it.
     
    Best regards,
     
    Artur Stepniak
  • Vinoth Selvam Profile Picture
    1,590 Super User 2025 Season 2 on at
    Yes i have also tried and we dont have a proper documentation on these.
     
     
    It was very helpful.

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 > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 261 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 198 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard