Defining a Generic Derived Column Function

We are currently defining derived column functions using a FunctionsMap, specifying a separate function for each object type.
However, many of these functions perform identical operations.
These identical functions operate only on properties that share the same name and type across multiple object types.
Is it possible to define a single, reusable derived column function that can operate on these properties regardless of the specific object type?
This would avoid redundant function definitions.

Currently functions don’t support interfaces or unions of object types I believe. So you would need to define one function for each object type, but you could still rely on the same underlying function, with something like:

    @Function()
    public async getObjectTypeAMap(objects: ObjectSet<ObjectTypeA>): Promise<FunctionsMap<string, Double>> {
        return this.getMap(objects);
    }

    @Function()
    public async getObjectTypeBMap(objects: ObjectSet<ObjectTypeB>): Promise<FunctionsMap<string, Double>> {
        return this.getMap(objects);
    }

    private async getMap(objects: ObjectSet<ObjectTypeA | ObjectTypeB>): Promise<FunctionsMap<string, Double>> {
        return ...
    }
1 Like

Sorry for the late reply. Your solution worked fine! Thanks so much!

1 Like