logo

NJP

Flow Action "Delete Multiple Records"

New article articles in ServiceNow Community · Feb 24, 2025 · article

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

Hi there,

Ever noticed that Flow Designer does come with a Flow Action "Update Multiple Records", though that there is no Flow Action "Delete Multiple Records"? The exact why, I don't know. What I can tell, with the Paris release ServiceNow introduced a Flow Action Step "Delete Multiple Records".

While not new (the Paris release is already some releases ago), I do want to share a Flow Action that I set up at most of my customers. I've also wrapped this in a project for the Developer Share so everyone can download this for free.

Sorry for the late share, I'm just far behind in all that I want to share with the ServiceNow Community 😀.

Flow Action

It's not uncommon to have a Delete Multiple Records operation in a Flow or Subflow directly. To achieve this now, you would need to create your own Flow Action. The Flow Action does not have to be over complex, simply inputs for the Table name and the Encoded query are required, and a Action step to perform the Delete Multiple Records.

Pre-Paris release

Pre-Paris I used to do this with a Script step in the Flow Action.

(function execute(inputs, outputs) { var table_name = inputs.table_name, encoded_query = inputs.encoded_query; if (gs.tableExists(table_name)) { var now_GR = new GlideRecord(table_name); var isValidQuery = now_GR.isValidEncodedQuery(encoded_query); if (isValidQuery) { now_GR.addEncodedQuery(encoded_query); now_GR.deleteMultiple(); } } })(inputs, outputs);

While you can create a GlideRecord query with "deleteMultiple()" with way less scripting, the above scripting verifies that the table exists and that the encoded query is actually valid. This prevents deleting records by accident 😀.

Flow Action step "Delete Multiple Records"

The "Delete Multiple Records" Flow Action step looks fairly straightforward. Table, Conditions, Order by, Sort Type, Run Business Rules and Workflow (in scripting known as "setWorkflow()"), Don't fail on error. Personally I don't know why there are inputs for "Order by" and "Sort type".

Tables

Interesting fact is that you can select any Table while in other parts of the platform you might notice that some system tables are not listed unless you add them to System Property "glide.ui.permitted_tables".

Update System Fields

Originally the Flow Action step came with an input "Update System Fields". This would be the equivalent of scripting "autoSysFields()". In current releases, this input has been removed (or hidden?). In which release exactly this was removed I couldn't find, though it should be either Quebec, Rome, San Diego, or Utah.

Count

The Flow Action step also comes with a very sweet result… a count of the deleted records!

Custom Flow Action

With the above, creating a custom Flow Action isn't complicated or time-consuming. Below are three (3) screenshots covering all details. With this, the Flow Action is ready to be used in Flows and Subflows directly.

1) Inputs

01.png

2) Delete Multiple Records step

02.png

3) Outputs

03.png

Share

While you can re-create the above Flow Action, I also made this available as a Share project:

- Flow Action "Delete Multiple Records"

---

That's it. Hope you like it. If any questions or remarks, let me know!

C If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful. Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

Kind regards,

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

LinkedIn

View original source

https://www.servicenow.com/community/now-platform-articles/flow-action-quot-delete-multiple-records-quot/ta-p/3185788