logicapps icon indicating copy to clipboard operation
logicapps copied to clipboard

Accessing Array elements in DotLiquid template throws undefined error

Open MithunChopda opened this issue 1 year ago • 10 comments

Describe the Bug with repro steps

  1. Setup an action to trigger every time a file is uploaded to Blob storage.
{
  "type": "ApiConnection",
  "inputs": {
    "host": {
      "connection": {
        "referenceName": "azureblob-3"
      }
    },
    "method": "get",
    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('https://<accountname>.blob.core.windows.net/'))}/triggers/batch/onupdatedfile",
    "queries": {
      "folderId": "JTJmaGlyaW5nZmVlZHN0b3Jl",
      "maxFileCount": 10,
      "checkBothCreatedAndModifiedDateTime": false
    }
  },
  "recurrence": {
    "interval": 15,
    "frequency": "Second"
  },
  "splitOn": "@triggerBody()",
  "metadata": {
    "JTJmaGlyaW5nZmVlZHN0b3Jl": "/<containername>"
  }
}
  1. Setup a "Get blob content (V2)" action to download JSON file from Blob storage.
{
  "type": "ApiConnection",
  "inputs": {
    "host": {
      "connection": {
        "referenceName": "azureblob-3"
      }
    },
    "method": "get",
    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('https://<accountname>.blob.core.windows.net/'))}/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Id']))}/content",
    "queries": {
      "inferContentType": true
    }
  },
  "runAfter": {}
}
  1. Setup a "Parse JSON" action to parse the downloaded json content. This is the content that will be passed to "Transform JSON to JSON" action.
{
  "type": "ParseJson",
  "inputs": {
    "content": "@decodeBase64(body('Get_blob_content_(V2)')['$content'])",
    "schema": {
      "type": "object",
      "properties": {
        "examDate": {
          "type": "string"
        },
        "examids": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "object",
                "properties": {
                  "idtype": {
                    "type": "string"
                  },
                  "idvalue": {
                    "type": "string"
                  }
                }
              }
            },
            "required": [
              "id"
            ]
          }
        }
      }
    }
  },
  "runAfter": {
    "Get_blob_content_(V2)": [
      "SUCCEEDED"
    ]
  }
}
  1. Setup Liquid "Transform JSON to JSON" action.
{
  "type": "Liquid",
  "kind": "JsonToJson",
  "inputs": {
    "content": "@body('Parse_JSON')",
    "map": {
      "source": "LogicApp",
      "name": "proposed-hiring-record-map-v1.liquid"
    }
  },
  "runAfter": {
    "Parse_JSON": [
      "SUCCEEDED"
    ]
  }
}

What type of Logic App Is this happening in?

Standard (Portal)

Are you using new designer or old designer

New Designer

Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg

Yes

Workflow JSON

No response

Screenshots or Videos

Sample JSON payload to test with

{
  "examDate": "2023-12-31",
  "examids":
    [
      {
        "id": {
          "idtype": "examId",
          "idvalue": "123456"
        }
      },
      {
        "id": {
          "idtype": "centerId",
          "idvalue": "654321"
        }
      }
  ]
}

Sample liquid template

Accessing content.examids throws undefined, undefined error and workflow execution stops. Accessing any array element throws undefined exception

{
    "examDate": "{{ content.examDate }}"

    {{ content.examids.size }}
}

Browser

Chrome, Safari, IE

Additional context

No response

AB#25342581

MithunChopda avatar Oct 03 '23 01:10 MithunChopda