Skip to main content

Notifications

Copilot Studio - General
Answered

Convert table variable to a string for Power Automate flow

(1) ShareShare
ReportReport
Posted on by 33

Hi,

 

I have a table from an adaptive card, and I can't seem to concatenate this table to a string so I can send the variable to PA.

 

I tried using the the JSON() formula, but it does not support the table data type.

JSON cannot serialize.png

 

I have tried to concatenate the table to a string, but using Concatenate(Topic.selectedOptionsTable, "") returns an empty string, despite the table having values in it.

 

The adaptive card has the following JSON formula: 

{
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
      {
         "type": "Input.ChoiceSet",
         "id": "selectedOptionsTable",
         "isMultiSelect": true,
         "choices": [
            {"title": "Fire Protection", "value": "Fire"},
            {"title": "Drought Protection", "value": "Drought"},
            {"title": "Flood Protection", "value": "Flood"},
            {"title": "Extreme Temperature Protection", "value": "ExTemp"},
            {"title": "Crop Disease Protection", "value": "Crop Disease"},
            {"title": "Crop Pest Protection", "value": "Crop Pest"}
         ],
         "style": "compact"
      }
   ],
   "actions": [
      {
         "type": "Action.Submit",
         "title": "Submit",
         "data": {
            "cardSubmit": true
         }
      }
   ]
}
 
If I send the table variable as a message I can see it is a column table, in square brackets, with the values selected. For example: [“Fire”,“Drought”,“Flood”,“ExTemp”]
 
Am I concatenating this wrong? How can table variables be used?
 
Thanks
Categories:
  • Nina131 Profile Picture
    Nina131 33 on at
    Re: Convert table variable to a string for Power Automate flow

    Thanks so much!

  • Verified answer
    HenryJammes Profile Picture
    HenryJammes on at
    Re: Convert table variable to a string for Power Automate flow

    Hi  @Nina131,

     

    For simple arrays, you can use the JSON formula, e.g.:

     

    JSON([1, 2, 3]) 

     

     

    But, for more complex cases, there's actually an undocumented node that you can set using the code editor view:

     

     - kind: SetTextVariable
     id: setVariable_IzY7HO
     variable: Topic.varYourString
     value: "{Topic.varYourTable}"

     

     

    HenryJammes_0-1708371465086.png

     

  • Nina131 Profile Picture
    Nina131 33 on at
    Re: Convert table variable to a string for Power Automate flow

    Hi, 

    I have found a very tedious solution, so if anyone has a better solution, please add it here.

     

    After some trial and error, I have set 6 separate variables named Value1 to Value6. They check if the row count of the table is greater than the current index, and return the field using Index() if true, else "". Then I concatenate the value variables into a string. 

     

    eg. 

    Value1 = If(  1 <= Topic.RowCount,  Index(Topic.selectedOptionsTable, 1).Value,  "")

     

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

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard