Mongo Delete Objects Step

Use this step to delete the JSON objects in the Mongo DB.

Last published at: April 16th, 2026

clsMongoDeleteObjects Step

Description:

The Delete JSON Objects in MongoDB step enables a FlowWright workflow to locate and delete one or more documents from a MongoDB collection using a JSON filter.

This step is commonly used when workflows need to remove obsolete, processed, expired, or temporary business data from MongoDB. Rather than deleting an entire collection, the step targets only those documents that satisfy the configured filter condition, allowing workflows to safely remove specific records while preserving all other data.

The step connects to a configured MongoDB database, accesses the specified collection, applies the supplied JSON filter, and deletes all matching documents.

Typical uses include:

  • Removing completed workflow records
  • Deleting expired sessions
  • Cleaning temporary application data
  • Purging archived audit records
  • Removing obsolete inventory entries
  • Synchronizing deleted records with external systems
  • Automating data retention policies

The deletion operation is controlled entirely by the JSON filter supplied in the step configuration.

 

Inputs

  • Select MongoDB Connection String – Selects the configured MongoDB connection used to access the database.
  • Enter Database Name - Specifies the MongoDB database containing the target collection.
  • Enter Collection Name - Specifies the MongoDB collection from which documents will be deleted.
  • Enter JSON Filter to Match Objects for Deletion - Defines the MongoDB JSON filter used to identify the documents that should be removed.
 

 

Returns

  • True – The delete operation completed successfully. Matching documents were removed from the MongoDB collection.
  • False - The delete operation failed because of a connection problem, invalid configuration, invalid JSON filter, missing collection, or another execution error.
 

 

 

Usage:

The Delete JSON Objects in MongoDB step is typically used after workflow logic determines that certain MongoDB documents are no longer required.

During execution:

  1. Connect to the selected MongoDB server.
  2. Open the specified database.
  3. Access the configured collection.
  4. Apply the JSON filter to locate matching documents.
  5. Delete all matching documents.
  6. Follow either the True or False return path based on the execution result.

A typical workflow might look like this:

 

Typical workflow scenarios include:

  • Deleting expired customer sessions
  • Removing processed queue messages
  • Cleaning temporary workflow documents
  • Purging completed audit records
  • Removing obsolete configuration entries
  • Synchronizing deletions with external systems
  • Enforcing document retention policies

 

Prerequisite:

Navigate to the Integration - Connections page. Create a new MongoDB connection string as shown below. Then click the Test button to validate the connection response. 

 

Example:

Let’s build and execute the “clsMongoDeleteObjectsDef” example.          

  • Create a new process definition named “clsMongoDeleteObjectsDef” and open it in designer mode. 
  • Drag “clsMongoGetObjects, and clsMongoDeleteObjects” steps to the canvas. 
  • Connect the dots between the “Start” and other steps, as shown above.
  • Define a variable or global required to store JSON objects. 
  • Click the "clsMongoGetObjects" step to configure its "Required" properties. Provide a name for the step. Select the MongoDB connection string from the drop-down list. Provide the database name. Provide the collection name. Provide the variable or global reference to store the JSON object fetched during execution. Click the Save button. Note: Click the "AI Predict" button for the Copilot to add new process steps that match your process description. 

 

  • Click the "clsMongoGetObjects" step to configure its "Optional" properties. Provide a JSON filter to match the object. Note: This configuration is optional; if left empty, the step will fetch all JSON objects. 

 

  • Click the "clsMongoDeleteObjects" step to configure its "Required" properties. Provide a name for the step. Select the MongoDB connection string from the drop-down list. Enter the database name. Enter the collection name. Enter the JSON filter to match the objects for deletion. Click the Save button. Note: Click the "AI Predict" button for the Copilot to add new process steps that match your process description.

 

  • Click the "clsMongoGetObjects" step to configure its "Required" properties. Provide a name for the step. Select the MongoDB connection string from the drop-down list. Enter the database name. Enter the collection name. Enter the variable or global reference to store the JSON object fetched during execution. Click the Save button. Note: Click the "AI Predict" button for the Copilot to add new process steps that match your process description.

 

  • Click the "clsMongoGetObjects" step to configure its "Optional" properties. The JSON filter for matching objects is intentionally left empty. Note: The step shall fetch all the JSON objects. 

 

  • The “Logging” configuration is necessary for documentation and to measure workflow progress and percent complete. This is done by configuring the step state and percent fields individually, as shown below. Configure the “Logging” using the following properties.

 

  • Save the process definition, create a new instance, and execute it. Render the process instance. Click the process step to view its variables. The “clsMongoDeleteObjects” step should delete the JSON objects from MongoDB as configured.  

 

Tips:

  • Always use the most specific JSON filter possible to avoid deleting unintended documents.
  • Test deletion filters in a development or staging environment before deploying to production.
  • Consider archiving business-critical data before deleting it.
  • Route the False path to logging and notification steps to simplify troubleshooting.
  • Use workflow approval steps before performing large-scale deletion operations.
  • Implement backup and recovery procedures for production databases.
  • Combine this step with Get a List of Objects Using a JSON Filter Condition, Update JSON Objects in MongoDB, Business Rule, Generate Audit Report, Send Email, or Log Message steps to create complete MongoDB lifecycle management workflows.

 

Notes:

  • A valid MongoDB connection must exist before this step can execute.
  • Database and collection names should reference existing MongoDB objects.
  • A valid JSON filter is required to determine which documents will be deleted.
  • Incorrect JSON syntax or connection failures may cause execution to follow the False return path.
  • The step deletes only the documents that satisfy the configured filter.
  • The True and False return paths should always be used to implement appropriate workflow success and error handling.
  • Execution details, deletion status, and any errors are recorded in the FlowWright workflow execution log.

 

Delete JSON Objects in MongoDB vs. Update JSON Objects in MongoDB:

Both MongoDB workflow steps modify data within MongoDB collections, but they perform different operations.

Delete JSON Objects in MongoDB Update JSON Objects in MongoDB
Permanently removes matching MongoDB documents. Modifies matching MongoDB documents while retaining them.
Requires only a JSON filter to identify documents for deletion. Requires both a JSON filter and a JSON update expression.
Used for data cleanup and lifecycle management. Used for maintaining and synchronizing existing data.
Performs delete operations. Performs update operations.

As a general guideline:

  • Use Delete JSON Objects in MongoDB when workflow execution needs to permanently remove documents that are no longer required.
  • Use Update JSON Objects in MongoDB when existing documents should be modified while remaining in the collection.

 

Definition Sample:

You may download the sample workflow definition from the link provided and import it into your FlowWright environment.

Note: Verify and complete any missing configuration after importing the sample, including:

  • MongoDB connection string
  • Database name
  • Collection name
  • JSON deletion filter
  • Success and error handling
  • Workflow branching
  • Appropriate backup or archival procedures before production use

After verifying the configuration, save and publish the workflow before execution.

Click here to download the sample file.