Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

azure logic apps - LogicApp - how to use length to check if collection is empty

In my JSON results, I'm trying to see if a particular object exists, and if it does exist, what is the count. I'm using length expression but it seems to be failing for me with error:

The template function 'lenth' is not defined or not valid.

Here is my Get_Ticket object:

    "TicketInfo": {
        "key1": "val1",
        "key2": "val2",
        "key3": "val3"
    "TicketEquipmentInfo": [{
        "EquipKey1": "val1",
        "EquipKey2": "val2"
    }, {
        "EquipKey1": "val3",
        "EquipKey2": "val3"

Here is my expression:

if(contains(body('Get_Ticket'), 'TicketEquipmentInfo'), if(greater(lenth(body('Get_Ticket')['TicketEquipmentInfo']), 0), 'Found at least 1 piece of Equipment', '<leave blank, empty array found>'), '<leave blank, no array found>')

What am I doing wrong? Also open to suggestions to make this expression more efficient without having to modify the logic app design.

question from:https://stackoverflow.com/questions/65832633/logicapp-how-to-use-length-to-check-if-collection-is-empty

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There's a typo - use not lenth but length.

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share