How do I bulk delete ontology objects?

In ontology explorer I can use the delete action to delete one at a time, but it won’t work when selecting more than one ontology object. I assume this means I need a new action to delete many at time? Not sure how to do this…

Deleting objects in bulk is not directly configurable from the Ontology Manager to add a layer of protection here.

To set this up manually, create the following Typescript function:

@OntologyEditFunction()
public deleteMultipleObjects(objects: ObjectSet<DemoObjectType>): void {
   objects.all().forEach(o => {
      o.delete()
   })
}

Then make sure you wrap this function in an action and you can pass an object set through to be deleted in bulk!

An action can be applied to multiple objects by toggling “Allow multiple values” in the object reference parameter. Then in Workshop, an Object Table can use “enable multi-select”, which creates checkboxes for each row and a “Select all” checkbox in the table headers row. These selected objects can then be collectively passed to the action (example below).

image

I don’t know if there is a limit to the number of objects that can be deleted by an action.

More info: palantir foundry - How can I apply an Action to more than one object in a Workshop table? - Stack Overflow

Update: This solved the issue – An action can be applied to multiple objects by toggling “Allow multiple values” in the object reference parameter. Then in Workshop, an Object Table can use “enable multi-select”, which creates checkboxes for each row and a “Select all” checkbox in the table headers row. These selected objects can then be collectively passed to the action.

https://community.palantir.com/t/how-to-bulk-apply-an-action-function-to-all-existing-objects/963/2

1 Like

To be a bit more exhaustive on this question: Flushing objects also depends how were those object created : via action ? functions ? Present in the backing dataset ?

You have a few options depending on the above:

  • If the object comes from the backing dataset: you can change your pipeline to flush the dataset (e.g. snapshot it by limiting to zero rows)
  • If the object were created by users (via actions or functions) you can drop all edits on the Object Type. You can do this in Ontology Manager. See https://www.palantir.com/docs/foundry/object-edits/how-edits-applied#how-to-discardwipedelete-existing-user-edits
  • If you want to delete only a subset of the objects and not “all” you will need to use an action.
    • You can create an action with an array of objects to delete. The array can be quite big (10k see https://www.palantir.com/docs/foundry/action-types/scale-property-limits).
    • You can create the same action and call it via Automate on all objects (so that it will batch 10k by 10k until all objects are deleted)
    • You can use a functions + Action - but it has no advantage compared to use a simple action + array of objects to delete. You can however write some logic to decide whether or not a given object should be deleted.