# MIGXDB AfterSave snippet to trigger on bulk delete and after CSV import / upload

**URL:** <https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906>\
**Category:** Extras\
**Tags:** migxdb\
**Created:** [July 24, 2023, 2:59pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906 "2023-07-24T14:59:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadakbar](https://community.modx.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nadakbar](https://community.modx.com/u/nadakbar)\
**Post date:** [July 24, 2023, 2:59pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/1 "2023-07-24T14:59:00Z")

</div>

Hi All

As the subject of this post suggests, i would like my afterSave snippet to trigger when i upload a CSV and when i do a mass delete.

If i edit one item or delete one item then it triggers but anything that revolves around a mass change such as a migxDB import via CSV or a mass delete does not trigger anything.

Anything i can do quickly to resolve this, i am happy to modify the core or the CSVImport Processor in migx to accomplish this. Also would be a good feature to add as another hook if possible.such as “afterImport” or “afterMassEdit”

version 2.8.3 Modx

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 24, 2023, 3:04pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/2 "2023-07-24T15:04:47Z")

</div>

> [@nadakbar](#):
>
> i am happy to modify the core or the CSVImport Processor in migx to accomplish this.

You can create a custom processor in your own package.  
You don’t have to modify the MIGX code.

---

<div class="post-metadata">

**Author:** ![nadakbar](https://community.modx.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nadakbar](https://community.modx.com/u/nadakbar)\
**Post date:** [July 24, 2023, 3:37pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/3 "2023-07-24T15:37:02Z")

</div>

Do i simply follow the same structure in my own package, so **my\_package\>processors\>mgr\>default\>importcsv.php** and then modify that accordingly to match what i want it to do.

---

<div class="post-metadata">

**Author:** ![nadakbar](https://community.modx.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nadakbar](https://community.modx.com/u/nadakbar)\
**Post date:** [July 24, 2023, 3:46pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/4 "2023-07-24T15:46:39Z")

</div>

That worked 🙂

I added the following to the top of my custom importcsv and it now triggers my aftersave i assigned to that config

```auto
$config = $modx->migx->customconfigs;
$hooksnippets = $modx->fromJson($modx->getOption('hooksnippets',$config,''));

if($hooksnippets["aftersave"]){
    $modx->runSnippet($hooksnippets["aftersave"]);
}

```

Its not elegant or fancy but i just needed it to trigger a snippet on any kind of update and the importcsv was not triggering… I will look into the bulkupdate and emptytrash ones too as i probably need it to trigger on those also

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 24, 2023, 3:58pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/5 "2023-07-24T15:58:11Z")

</div>

Depending on what you are doing in your “aftersave” hook snippet, it may also be an option to instead override the `save()` function in your custom class. (The one that extends `xPDOSimpleObject` in the “model” folder.)

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [July 24, 2023, 4:14pm UTC](https://community.modx.com/t/migxdb-aftersave-snippet-to-trigger-on-bulk-delete-and-after-csv-import-upload/6906/6 "2023-07-24T16:14:47Z")

</div>

maybe worth a FR on github
