typescriptpalantir-foundryfoundry-slate

Slate - TypeScript - return the required info out of a promise


my code

@Function()
@Edits(XYZ)
public async fctLargestNumber(): Promise<XYZ[]> {
    const maxObject = Objects.search()
            .xYZ()
            // .groupBy(e => e.lngPlanningNumber.topValues())
            // .segmentBy(e => e.lngPlanningNumber.topValues())
            // .filter(data_column => data_column.lngPlanningNumber.byIRanges({ min: 100000, max: 999999 }))
            .orderBy(data_column => data_column.lngPlanningNumber.desc())
            .takeAsync(1)
            //.valueOf();         
    return maxObject;

now i recieve an output like this:

[
{"typeId":"my-collection","primaryKey":{"id_pk":"ee1b1ac1-008b-479b-a748-01e8702927c9"}}
]

The question is now, how can i receive my result.


Solution

  • Partially Solved:

    @Function()
    @Edits(XYZ)
    public fctGetLargestNumber(): Integer {
            let  DataResult = Objects
                    .search()
                    .xYZ()
                    .orderBy(data_column => data_column.lngPlanningNumber.desc())
                    .take(1)[0];
        const result = DataResult.lngPlanningNumber ?? 0
        return result;
    }
    

    Attention !!!!! Changes to objects and links are propagated to the Objects.search() APIs after your function has finished executing. This means that Objects.search() APIs will use the old objects, properties and links. As a result, search, filtering, search arounds, and aggregations may not reflect the edits to the Ontology, including creation and deletion. Your function will need to handle this case manually.

    --> so i have to create new question to this.....