<p>If all you want to do is re-save all of the entries without making any modifications to them, you're best bet is to use the completely undocumented <code>TaskService</code> and trigger the <code>ResaveElements</code> task.</p>

<p>There is an example of how to do it from your plugin <a href="https://craftcms.stackexchange.com/a/823/57">here</a>.</p>

CC BY-SA 3.0
2014-07-20T01:52:38.937Z
That looks like it might be what I am looking for. Thanks! I am trying to trigger that from a widget that I created for my plugin, and so far I can't get it to work via a button click. I was able to get it to work successfully by hooking into an event (which is how I figured out that it works for me). Any chance I could get an example of how I could do that? Thanks again.
Chris
CC BY-SA 3.0
2014-07-20T02:21:32.700Z
Just have your form with the button point to an action on a controller in your plugin (http://buildwithcraft.com/docs/plugins/controllers).  Trigger the task there, then redirect back to where you were.  Or you could do it over AJAX since it's from a widget on the dashboard.
Brad Bell
CC BY-SA 3.0
2014-07-20T06:10:45.243Z
now that I've been playing with it a bit, it doesn't look like the ResaveElements is actually triggering the entries.onBeforeSaveEntry I have declared in my plugin. Should it trigger that?
Chris
CC BY-SA 3.0
2014-07-19T23:06:10.393Z
2014-07-19T23:06:10.393Z
2017-04-13T12:51:00.200Z
Brad Bell
<p>I've been working on a plugin that updates entry data based on the results from a json array using entries.onBeforeSaveEntry.</p>

<p>Since this API might put out different information in the future, I would like to create an "update all" button that would cycle through all entries and just save them rather than going through each one and clicking save manually. </p>

<p>Any ideas? </p>

<plugin-development><entries>
How could I create a button to loop through entries and re-save them?
# How could I create a button to loop through entries and re-save them?

(Asked by: username_0 on 2014-07-19)

I've been working on a plugin that updates entry data based on the results from a json array using entries.onBeforeSaveEntry.

Since this API might put out different information in the future, I would like to create an "update all" button that would cycle through all entries and just save them rather than going through each one and clicking save manually.

Any ideas?

**Tags:** plugin-development, entries


---

## 1 answers

### Answer by username_1 on 2014-07-19. Score: 1 | Accepted answer

If all you want to do is re-save all of the entries without making any modifications to them, you're best bet is to use the completely undocumented `TaskService` and trigger the `ResaveElements` task.

There is an example of how to do it from your plugin [here](https://craftcms.stackexchange.com/a/823/57).

> **Comments:**
> **username_0**: That looks like it might be what I am looking for. Thanks! I am trying to trigger that from a widget that I created for my plugin, and so far I can't get it to work via a button click. I was able to get it to work successfully by hooking into an event (which is how I figured out that it works for me). Any chance I could get an example of how I could do that? Thanks again.  
> **username_1**: Just have your form with the button point to an action on a controller in your plugin (http://buildwithcraft.com/docs/plugins/controllers).  Trigger the task there, then redirect back to where you were.  Or you could do it over AJAX since it's from a widget on the dashboard.  
> **username_0**: now that I've been playing with it a bit, it doesn't look like the ResaveElements is actually triggering the entries.onBeforeSaveEntry I have declared in my plugin. Should it trigger that?  

---

