Is it possible to direclty only include only 10 objects in a workshop object table widget?
You can use a Function that calls .takeAsync(10) on the object set and wire its output to the table’s input.
typescript
import { Function, ObjectSet } from "@foundry/functions-api";
import { MyObjectType } from "@foundry/ontology-api";
export class LimitFunctions {
@Function()
public async getTop10(objects: ObjectSet<MyObjectType>): Promise<MyObjectType[]> {
// Add .orderBy() before .takeAsync() if you need a specific sort
return objects.takeAsync(10);
}
}
Wire the function output as the table’s input. The function receives the full filtered object set, limits it to 10 rows, and returns the trimmed array.
Docs: Object Table widget
Thanks @ablumkin .
I was able to do it using the following,
import { ObjectSet, Osdk } from "@osdk/client";
import { MyObjectType} from "@ontology/sdk";
async function functionName(
objects: ObjectSet<any>
): Promise<Osdk.Instance<MyObjectType>[]> {
const response = await objects.fetchPage({
$orderBy: { propertyA: "desc" }, // highest values first
$pageSize: 10
});
return response.data;
}
export default functionName;