0

fill_elements in Trello nested Items

So I am trying to access some nested values "customFieldItems" in a JSON Datasource, but the card-data delivered by trello has some special structure, so I cannot find the correct way to use fill_elements here:

My first approach was:

@kf:fill_elements(/customFieldItems[2],"value","number")

 

This does not work and here is why:

In another item the customFiledItem No. 2 is ANOTHER Filed, because in Trello this field is not set. So it does not deliver an empty item, but the next available, which delivers another value and another ID:

So the nested customFieldItems have to be identified by the idCustomField here, which is a value within in the object. This is the main difference to all other related issues.

My next approch was then:

@kf:fill_elements(/customFieldItems[idCustomField='5c6194288df9a6263989291a'],"value","number");

But this does not work, I get the correct numbers but the empty elements are not filled now.

 

So how do I get this done? Thank you in advance!

 

1 comment

  • 0
    Avatar
    Rahul Bura

    Hey Yuriy,

    In this case, kf:fill_elements doesn't work if you are filtering by idCustomField. In this case what you will need is a LookUp.

    You have a name for every Trello card but not every trello card has the custom field 5c6194288df9a6263989291a so what you first need is to reference the Names of each card in your first column.

    Now in your next column, you're on the right track with using @/customFieldItems[idCustomField='5c6193fc86b88d7029686510']/value/text; to get the text for that Custom Field. However not every card has that field so we need to line that up. As mentioned the LookUp is going to help with that.

    The LookUp function has the following definition: LOOKUP(input, keys, results). In your case here are what should be used:

    - Input: Reference to your first column with all the Names.

    - Keys: Reference to all the Names of cards with the Custom Field in question.

    - Results: The value of the custom field: @/customFieldItems[idCustomField='5c6193fc86b88d7029686510']/value/text;

    So we have Input and we have Results - we need to figure out the Keys.

    That would need some XPATH knowledge. We'll need to get to the same level as Name and get the corresponding name for each Custom Field - to do that this is what you need:

    @/customFieldItems[idCustomField='5c6193fc86b88d7029686510']/following-sibling::name;

    The /following-sibling::name basically looks at the names for each card that has the Custom Filed you're filtering on. With this information you can now construct your LookUp as such:


    LOOKUP(
    &Column1,
    @/customFieldItems[idCustomField='5c6193fc86b88d7029686510']/following-sibling::name;,
    @/customFieldItems[idCustomField='5c6193fc86b88d7029686510']/value/text;)


    Where Column1 is the name of the first column with names and you're using the & to do a results reference to it within the Lookup. So you're now looking up your Name's column and matching the corresponding custom field value against it. More info on XPATH here as well.

    Hope that helps!

     

     

     

Please sign in to leave a comment.