Delete Object(s)

Last modified: October 28, 2024

Introduction

The Delete object(s) activity can be used to delete one or more objects.

Properties

An example of delete object properties is represented in the image below:

delete object properties

This activity cannot be used to delete external objects. Use the Delete External Object activity to delete external objects.

There are two sets of properties for this activity, those in the dialog box on the left, and those in the properties pane on the right.

The delete object properties pane consists of the following sections:

Action Section

The Action section of the properties pane shows the action associated with this activity.

You can open a dialog box to configure this action by clicking the ellipsis () next to the action.

You can also open the dialog box by double-clicking the activity, or right-clicking the activity and selecting Properties.

Object or List

The name of the object or list of objects that will be deleted. If you choose a list, all objects in that list will be deleted.

Refresh in Client

This setting defines whether data sources are rerun after objects are deleted from the database.

Default: No

Activity Used in a Microflow Called from the Client in a Responsive Web App or PWA

If Refresh in client is set to No, the data sources are not rerun, and widgets which need to reload data will still display the object (or objects).

If set to Yes, the deletion is reflected across the client, which includes reloading the relevant data sources.

Activity Used in a Microflow Called in an Offline-First App

When inside a microflow that is called from an offline or native app, the Refresh in client option is ignored and functions as if it was set to No.

For more information, see the Microflows section of Offline-First Data.

Activity Used in a Nanoflow

The Refresh in client option is not configurable when the activity is used in a nanoflow.

All changes immediately take effect in the client while executing such a nanoflow, similar to when Refresh in client is set to Yes.

Limitations

When using the activity in a nanoflow accessible from an offline profile, please note the following limitations:

  • Deleting non-persistable objects is not supported
  • If the entity of an object passed to the activity has any associations with other entities in the domain model, the delete behavior for each of those associations must be set to Keep {associated entity name} object(s) (for more details, see the example below)
  • Setting a different delete behavior option triggers a consistency error
  • Before and after delete events are only triggered upon synchronization of the deleted object
  • Before and after delete events are not triggered for an object that does not exist in the runtime database
  • When you create an object in the client and optionally commit it, it does not exist in the runtime database until you synchronize it
    • Deleting such an object removes it from the device and does not require synchronization, and therefore the before and after events of the corresponding entity will not be triggered

For more information on associations’ delete behavior, see the On Delete Behavior section of Association Properties.

Example

The following example shows that one Customer object is associated with multiple Order objects:

The On delete of ‘Customer’ object option below should be set to Keep ‘Order’ objects:

Common Section

For more information on properties in this section, see Common Properties.

What Happens During a Delete?

Activity Used in a Microflow or a Nanoflow in a Responsive Web App or PWA

Clicking a Delete button or triggering a delete activity will initiate delete events. In addition, when an object is removed through the configured delete behavior, it will execute all before and after events.

In detail, the following graph shows what happens during deletions:

  • Events:
    • All before and after events are executed, and if any before-delete event returns false, an exception can be thrown
    • If an exception occurs during an event, all the applied changes are reverted with the default error handling behavior
    • Changes made prior to the rollback are kept
  • Database:
    • If an object has the Instantiated state, there will be no database communication required
    • For any other status, a delete query is executed in the database
  • Result:
    • The object is be removed from memory and (if applicable) from the database
    • All delete behavior for the associations is validated, and any associated objects are removed as well

Activity Used in a Nanoflow in an Offline-First App

Depending on the type of an object being deleted, the client acts as described below.

Deleting a Persistable Object Which Has Not Been Committed

  1. Removes the object from memory.
  2. Searches the device database for all objects that reference the deleted object.
  3. Clears all references to the deleted object from all objects found previously.

No before or after delete events will be executed in this case.

Deleting a Committed Persistable Object That Has Not Been Synchronized with the Runtime

  1. Removes the object from memory.
  2. Searches the device database for all objects that reference the deleted object.
  3. Clears all references to the deleted object from all objects found previously.
  4. Deletes the object from the device database.
  5. Clear all references to the deleted object from any uncommitted objects.

No before or after delete events will be executed in this case.

Deleting a Persistable Object That Exists in the Runtime Database

  1. Removes the object from memory.
  2. Searches the device database for all objects that reference the deleted object.
  3. Clears all references to the deleted object from all objects found previously.
  4. Deletes the object from the device database.
  5. Marks the object as deleted in the offline database, which makes it possible to synchronize the deletion with the server using Synchronize unsynchronized objects or Synchronize all objects.

Before and after events for the deleted object will be executed upon synchronization.

Deleting a Non-Persistable Object

Deleting an NPE is not supported in a nanoflow in an offline-first app.