How could an anonymous user start a Sharepoint workflow?

Advanced users for Sharepoint like creating workflows (WF). Sometimes they start to think that all the problems could be solved by implementing a WF. I’m talking on the Advanced users, those who do not want to open Visual Studio to create code based WFs. These peoples (like me) starts the Sharepoint Designer and make so many clicks to build up a Logic for a business case.

As we all know WFs can be triggered on a list item change, creation or manually. As sharepoint supports anonymous access to its sites an advanced user can think about WF solutions triggered by a new item creation by an anonymous user.

And after having implemeted the WF (s)he is dissappointed as the WF is not triggered. It’s intangible… a bug or feature? huh.. So let’s say this is a security feature from MOSS 2007 SP1.

Ok, what’s next?

Open Visual Studio and create some event handler and import them and… oh no… i don’t want to do that! – says our Advanced user.

Here you are a light workaround. We know now that the WF is not triggered in any case by an anonym user. Let’s think a bit. What if we update the list items created by an anonymous user? Yesss.. that is the solution. If an authenticated user update a list item the WF is triggered.. and wow here we come!

Ok, but how to implement that update? Powershell gives a hand again! Here is a little code to connect to a sharepoint site and get the actual list (which holds the items created by an anonym user) and update all the list items. So the content of our Update.ps1 powershell script file:

$site = new-object Microsoft.SharePoint.SPSite("http://moss")
$web = $site.AllWebs | where { $ -eq "testsite"}
$list =$web.Lists["anonymlist"]
$items = $list.items
foreach ($item in $items){
$Temp = $item["Title"]
write-host -foregroundcolor yellow $temp
start-sleep 1
start-sleep 10

Place this powershell script file (update.ps1) to the MOSS server (WFE or Application) and schedule using the built-in Windows Task scheduler. (How to do that? – check the previous post by clicking this link)

Please note that you should take care about Sharepoint carefully as like this script can start many workflows in a short time – Performance problems.. So in the next post i would like to show you a small code to copy items from one Sharepoint list to another one using powershell. In that case you only need to create a “new item” triggered WF for the new list.

Please note one more thing. This powershell script (Update.ps1) will connect the sharepoint site using the scheduled task “Run as/by” user. So please provide contributor rights to the corresponding sites/lists/items for that user on Sharepoint 🙂

Anyway you have the possibility to remotely connect the sharepoint sites. The how will be post as well 😀


11 thoughts on “How could an anonymous user start a Sharepoint workflow?”

  1. Nice solution, however i think it is better to subscribe to the ItemAdding event, and of course you can use powershell to this, with SharePoint Power EventReceiver 2007 solution.

    1. Thanks for the hint i’ll check it 🙂
      Okay, checked it. Seems to me a good solution also. But in case of having no access to the server itself (not able to place a script or install any additional components or not having any farm admin account just a contributor account for the given site) you have to do it remotely (updating items). So in that case we need to connect remotely (i had an article on that) and update all the list items…

      I love CodePlex very very much 😀

  2. you should perhaps bold the variable names. I cant get it working, however i am not sure which are variables. Obviously http://moss should be replaced with your site name. But what about title? or anonymlist? are they things that are specific to my site?

  3. @whatsinanar:
    Yes, http://moss should be replaced with your URL, also
    in 3rd line, testsite should be replaced with your site’s name
    in 4th line, anonymlist should be replaced with your list’s name
    In this list, all items will be updated.
    You can actually alter the script to accept these as input parameters.

  4. recently the “sharepointryan” solution above failed us, i think due to a sharepoint update. So i am reevaluating your solution. However, i run into the following error “cannot index into a null array”. I have replaced the text in quotes as you have indicated. Seems like it cant find the list or list item? The list is called TEMP and the list item field is called Title .

    if you have any advice that would be great.

    1. Hello,
      Well it seems to me that the script was not able to find the $web olbject itself (the root site collection). Please correct the line
      $web = $site.AllWebs | where { $ -eq “testsite”}
      to use the your own website name (change the teststie string) if this TEMP list can be found on the root web site collection than you need just to have the next line:
      $web = $Site.RootWeb
      i think that is the root cause of the filaure. Then check the $web object by typing simply the $web into the powershell window. 🙂 it should not be empty

  5. Hi.
    If you do not need to start the workflow immediately after the list item update, the solution may be starting of the workflow by scheduler. Take freeware product HarePoint Workflow Scheduler (http://www, and configure it to start the workflow each minute. Of course, you need to modify the workflow to check the new items first to do not process the same item again and again and to take into the process new items only but this way works in most cases.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s