Condition ($when) inside an container iteration in an json adaptive card

Viewed 169

I have a list of "fields" I'd like to display by an adaptive card. The information I want to display depends on the field type. I use a container to run through my fields. Foreach field, I want to display a Input which type depends on the fieldType.

I can't find a way to use the $when condition.

On the json under, I tried to move the "$" on different places ("$when": "${fieldType == 1}","$when": "{${fieldType} == 1}", "$when": "{$fieldType == 1}"...) but I think the doc says to put it that way.

Here is a part of the adaptive card template

{
  "type": "Container",
  "$data": "${attributeData.data}",
  "spacing": "medium",
  "items": [
    {
      "type": "TextBlock",
      "weight": "Bolder",
      "text": "${fieldName}",
      "wrap": true
    },
    {
      "type": "Input.Text",
      "$when": "${fieldType == 1}",
      "id": "${fieldId}",
      "placeholder": "Add a comment",
      "isMultiline": true,
      "value": "${fieldValue}"
    },
    {
      "type": "Input.Date",
      "$when": "${fieldType == 2}",
      "id": "${fieldId}",
      "value": "2017-09-20"
    }
  ]
}

Here are part of the data

{
  "attributeData": {
    "data": [
      {
        "fieldId": 1,
        "fieldName": "Texte libre 1",
        "fieldValue": "Voici un texte",
        "fieldType": 1
      },
      {
        "fieldId": 2,
        "fieldName": "Montant libre 1",
        "fieldValue": "101",
        "fieldType": 0
      },
      {
        "fieldId": 3,
        "fieldName": "birthDate",
        "fieldValue": "2001-05-19",
        "fieldType": 2
      }
    ]
  }
}

Does someone know how to do this ? Maybe is there another way to get what I need ?

Thank you for your time

1 Answers

I fixed that by updating my adaptivecrads package...

Related