I’m trying to filter a list within a list and getting stuck on the logic to use.
The list “calendarDate” is a list. Each item in calendarDate contains three lists (Tasks, Touchpoints, autoTasks) – I am trying to target the list “autoTasks” and within that match the “type” property to “hazard”.
“calendarDate” List
contains “autoTasks” List
contains property “type” = “hazard”
I have tried many variations of filtering and loops, but cannot seem to make this work. I’ve tried about ten variations – this is the latest, which I hope shows what I’m trying to do:
I think you wanted to get the “autoTasks” property from “j” ?
Suggestion: Use the print block to output/print the structure of the calendarDate variable. Based on what you see there, follow the structure in your processing logic.
I’ve been using the print block to see the structure of the calendarDate variable, it contains a list of properties and arrays (of which autoTasks is one)
Latest attempt:
for each item j (which is a list) in calendarDate:
it gets the value of the autoTasks.type property (btw, you can use the dot notation now in a single “get property” block) and checks if the value is hazard
if the value is hazard, it returns true, otherwise false
in the end, you will end up with a list of true and false values.
Is this what you need?
If not, please share the output of print for calendarDate and describe the end goal.
I’d like to return a list of objects from each of the autoTasks lists where the “type” = “hazard”
In each item of calendarDate, I need to find the autoTasks list and then inside of that list, I need to evaluate the “type” = “hazard”. I’d like to return a list of objects where the “autoList.type” = “hazard”.
It would help to see an expanded version of the autoTasks sublist
If you need to return a list of objects, then right here (see below) you should be returning not a result of the comparison (which is a boolean) but the actual object (item) if the condition is true.
After trying some more, I’ve managed to get the filter to refine my list down to the items that have the “autoTask” property and the filter item “j” shows these individually, however I can’t seem to get these individual results filtered to “type = hazard” and assigned to a variable. This variable “result” comes back undefined.
Can you point me at why I can’t get this property type logic to work?