You may also be interested in: SharePoint Fest Denver 2013
Editor's note: Contributor Khoa Quach is SharePoint Development Leader and developer at Affirma Consulting. Follow him @quachhongak
I recently received a request from a client which seemed very straight forward at first but ended being a little trickier than I expected. So hopefully this will help someone out.
- Client has a SharePoint 2010 publishing site
- Client wants to allow anonymous access to the entire site
- Client has a simple contact form. It needs to be a SharePoint list. Once submitted, it needs to email different internal groups depending on the subject selected.
Well, I thought it will be as simple as this:
- Set up the web application to allow anonymous access – pretty straight forward
- Go to the site collection (publishing site template, this is actually important)– allow access for anonymous user to the entire site collection
- Create the SharePoint list
- Provide “Add item” access to the Anonymous users.
- Create the Form using InfoPath – why not right?
- Create the SharePoint Workflows with “If” statements that redirect according to the subject selected from a Choice type of field. Start it when an item gets created. Publish.
Actually, if you go that route there are going to be a couple of issues:
- I encountered issues with the InfoPath form. Signed-in users were able to see the form but not anonymous access. Even, with the anonymous access set properly. I actually remedy this by disabling the following feature
- After that, the form was showing for anonymous users and at submission, the entry was added to the SharePoint list but the workflow was not kicking in for anonymous users. (Grrrrr….) There is actually a solution for that, I will develop later on.
Ok, well here is what I did. I think, from my research and different conversations I've had with other SharePoint techies, it is an acceptable solution. Please comment.
- Set up the web application and the site collection for anonymous access.
I am not going to expand on this as there are plenty of great articles out there that will describes step by step how to go about this. The following article is the one I used: http://www.topsharepoint.com/enable-anonymous-access-in-sharepoint-2010
At this point we should be able to access the SharePoint site anonymously. Yay!
- Create the SharePoint list
This depends on your requirements. Let’s say that our form will contain the following fields:
- Title | single line of text | required
- Subject | Choice (HR/Marketing/IT) | required
- Body | Multiple lines of text | required
Simple enough, now let’s give “Add item access to the anonymous users”
- Go to your newly created SharePoint list, go to the list permissions
- Stop inheriting the permissions (if not already done)
- You should see the Anonymous Access icon
- Once you click on it, select the “Add items” option checkbox. This should be good for our scenario but feel free to add more options if necessary
- Note: I had the options originally greyed out and was not able to activate. If you are in the same situation, this may be because of list settings >> advanced settings >> item-level permissions. Do not set to “Read items that were created by the user” or “Create items and items and edit items that were created by the user”
- Click OK
OK. At this point we provided the ability to our anonymous users to add items.
Then create your InfoPath form. I will not go into detail and assume that this is performed easily, there are no options in InfoPath that should be different from a regular InfoPath form on a portal (Hint: you have to go to SharePoint Designer. If you need further details on that I could write something in a future post).
However this is optional, you could use the default form provided by SharePoint or even create new forms from scratch.
At this point, there is going to be an issue if you try access your forms whether it is an InfoPath form or a regular SharePoint form page.
In fact, if you try to access the SharePoint list “All items” view or any of the form views (Edit/New/Display), your anonymous user will encounter an error message. From a SharePoint page displaying the InfoPath form in a web part, you will encounter an error message too.
Not good. I learned that since our SharePoint site collection template was the publishing site infrastructure, the SharePoint feature “ViewFormPagesLockdown” was actually impeaching anonymous users to access system settings pages. Therefore, we need to disable that feature. This also means that all the SharePoint lists and document libraries' views will be accessible to anonymous users. (I have yet to find a way around web.config file? Any input is welcome)
Anyway, here is how to enable/disable:
At this point our anonymous users can go and add new items to the contact form list.
Ok, last couple of steps.
Creating SharePoint workflows should be easy enough at this point. But I will hold off until I read this excellent article/solution at: http://blogs.ibs.com/duane.odum/lists/posts/post.aspx?id=19. In fact, your workflows will hang if run as an anonymous user. The reason why is that “SharePoint Designer workflows will not trigger for items added or updated by anonymous users. [Note: Prior to SP1, declarative workflows could run under System Account. If you have upgraded to SP1 then this is no longer possible. See comments below for possible solutions]" .
I follow, to the letter, the steps from the previous link and it worked out like a charm.
Note: If during your search you come across this article at: http://blog.furuknap.net/enabling-declarative-workflows-for-anonymous-users-in-sp20102007; this will not work for items added from the UI but only email added items. Good resource for another project though.