SharePoint 2010 - Update All List Items SharePoint Designer Workflow Action
Thursday, July 15, 2010 at 1:52PM Out of the box - SharePoint provides quite a few different Workflow Actions, but strangely missing was a Workflow action that can loop through and update all items within a list.
Figure: Update List Item (but only works with one item)
Further to my shock was that someone out there (cough Codeplex) hasn't written one yet. So last night I sat down and start to code. There will be another article about coding and packaging a SharePoint Workflow Activity, but right now, I need to shove my baby out the door.
UPDATE LIST ITEMS v1.0 INSTALLATION
Everything in one WSP file: grab it here
The package includes 3 objects:
- WorkflowActivity.dll - goes in the GAC
- WorkflowActivity.ACTIONS - goes into <SharePointRoot>\TEMPLATE\1033\Workflow\WorkflowActivity.ACTIONS
- <authorizedType> entry needed in Web.Config - I've included a Web Application feature that will do this
To activate the web application feature
UPDATE LIST ITEMS v1.0 USERS GUIDE
In SharePoint Designer, select the "Update All List Items" action from the menu
Or just do the inline typing
There is only 1 dialog for this action - I cheated and reuse the dialog from Update Item Workflow Action
Unfortunately, because I cheated and use Microsoft's dialog - it won't let us finish without specifying a List Item - hence I use the sentence "Update all items in this list (ignore list item)" - sorry - hope that was clear.
OK and trigger the workflow
SUMMARY NOTES
- In SharePoint, a workflow can not trigger itself. So even though I have the workflow set against this list - it is only run on the last item.
- And because this is version 1 (v1.0) there's some really complex looking code for setting "People or Group" values. So I'm not sure if this works 100% in my implementation.
- Obviously, if your list is extremely large you are on your own :-)
- One other scenario this opens up is the facility to have a site workflow "trigger" a second workflow set on a particular list (remember - workflow can't trigger itself).
SharePoint in
code 




Reader Comments (24)
Thanks. It would be nice to see this with an optional filter option as well - update all items in a list where some condition is met, for example.
I suppose this could be very useful to force workflows to fire off on all items on a list. Thinking back to your list permissions example, if you update the list permissions in the Departments field, those aren't applied until the workflow is run again, so you run this guy and it updates the entire table, shooting off all the workflows.
After I wrote this I came across 3rd party custom actions that allows you to specify a CAML filter to select the list, which I thought was an interesting way of doing it.
I'm basically being lazy here and avoiding like crazy to have to build any sort of UI. That limits me to very basic field types or existing field types in SharePoint designer.
Why not just do the update the list using the DataSheet view of the list since you are updating all list items in the list?
@HD
The idea is to be able to modify multiple items automatically in a workflow. Including being able to update a different list.
One additional possibility is to trigger a second workflow on list-B.
So in List A, when you enter a record, it runs Workflow-A, which updates fields on List-B.
Workflows-B then trigger due to List-B changes.
I'm having trouble installing this feature.
I can't open the WSP so cannot see the content so I used STSADM to install it.
However, I don't see it in the list of feature to activate after deploying it.
I've done an iisreset thing that would help but nothing shows up.
Any help or suggestions gratefully received.
@Paul
A wsp file is a cab file, so you can rename it with a WorkflowActivity.wsp.cab and then open it up with explorer to see the contents.
Now you say that there's no feature after deploying this - are you checking the Web Application Feature list? The only feature is to add the necessary web.config modifications.
Please excuse my noob questions:
I have managed to get the files out of the wsp file.
I have placed the .dll and the ACTIONS files in the suggested locations.
I am stuck trying to update the web.config file.
It's not clear exactly how I should enter the authorizeType into the web.config.
I have entered it like this:
I can now see the Task listed in SharePoint Designer but when I click it nothing happenes.
Hi Paul,
You need to add this line to the web.config of the web application that you want to use the activity on:
<
authorizedType Assembly="WorkflowActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2fd155a2cc10bd81" Namespace="WorkflowActivity" TypeName="*" Authorized="True" />
I've downloaded and opened the WSP file, could you please explain where each of these files need to be installed.
This is a great solution but before I could deploy something like this on our server I would have to verify the security of the dll. Any chance you would share the Visual Studio project file instead of the compiled file?
I strongly recommend just installing the WSP file directly in the web application to avoid any fiddling. But I guess people are right to scrutinize what you download from the Internet :-)
There are 3 components:
WorkflowActivity.dll - goes in the GAC
WorkflowActivity.ACTIONS - goes into <SharePointRoot>\TEMPLATE\1033\Workflow\WorkflowActivity.ACTIONS
entry needed in Web.Config - see earlier comment.
Tim,
Code is unavailable since I've nuked the old demo machine I used to build the solution and it is in fact... let me check, yes it is in fact lost
Just Reflector my assembly, not much code in it and I don't obfuscate. Sorry! :-(
It installed fine and ran fine in dev and test, but last few time I've run it against a list, I get this error. I'm updating 1 field in a document library with about 30-40 items. It's a choice field and always is populated with with some choice.
Here's the error: "The workflow could not update the item, possibly because one or more columns for the item require a different type of information." I've checked and there's no missing required fields and the value being set is one of the choices for the field I'm trying to set.
Because SharePoint treats text fields and choice fields differently, I think the code I wrote to compile this activity can't handle choice fields.
thank you very much , you save my life :)
... I've built a web part that updates all items in a list by triggering individual work-flows - you just select the list, select the workflow, and push the button.
If all you wanted to do was to have a webpart that starts workflows on all items, why bother changing the items? Just tell workflow to start on them via the workflow service.
You can start workflows using JavaScript too - don't even need to deploy code.
http://spservices.codeplex.com/wikipage?title=StartWorkflow&referringTitle=Workflow
I installed the .wsp file in Sharepoint. I see activated the web application in the administration web site but when I started the workflow in the Sharepoint Designer I don't see the action. What's the problem? Thanks.
Hi
I dont know about this one, My problem was our SP wont allow us to import a WSP. So I wrote a solution using Java and HTML., It works, anyone interested?
HI Alan,
I'm very interested in your solution, where I can download? Thank you very much!
The solution involves adding a column to the your list, called (say) "update" and then using a CAML query to change the update column contents from "Set" to "Reset".
You can do this any way you like 9 I have buttons called "Do This" and "Do That", but the clever bit is that every time you change this field, you can trigger a workflow "on change"
The first line of the workflow is that it must only proceed if the "Update" field is "Set" so that you dont get two triggers!
And now we have a one-shot action that will process whatever you wish to your remaining columns, based on whats available in the workflow conditions and actions
I've even been importing data from other lists!
The beauty is that , by adding a simple Set/Reset Update column, this will work on any list
and, by adding more words, a single workflow can be directed to do many other operations
Still interested?
It's very interesting, it's complicated to install your solution? Thank you.
I've published the solution on my newly formed blog
I hope its understandable.
Hello khetienne,
Can you give me your URL of your blog? Thank you very much!
http://thesecretsharepoint.blogspot.co.uk/2012/05/sp2010-update-list-items-solution.html#comment-form