findColumn() don't work when creating task

I made it work with custom function:

get_vehicle_list = () => {

    list = from(bucket: "vehicle_list")

        |> range(start: -99y)

        |> findColumn(fn: (key) =>

            (key._field == "vehicleid"), column: "_value")

    return list

}

from(bucket: "operating_data")

    |> range(start: -5y)

    |> group(columns: ["vehicleid"])

    |> distinct(column: "vehicleid")

    |> map(fn: (r) =>

        ({

            _time: now(),

            _measurement: "vehicle_list",

            _value: r.vehicleid,

            _field: "vehicleid",

        }))

    |> filter(fn: (r) =>

        (contains(value: r._value, set: get_vehicle_list()) == false))

    |> to(bucket: "vehicle_list")
1 Like