Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a form that allows anonymous users to submit parking requests. I have an approval workflow set up but it won't start because anonymous users don't have permission to do so. Would an event handler make it possible to run the workflow on ItemAdded regardless of who adds it?

share|improve this question
add comment

3 Answers

here is a method that will solve this issue for you

public void StartWorkflow(SPWorkflowManager manager, string eventData, SPListItem listItem, SPWorkflowAssociation workflow)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPWorkflowCollection workflows = manager.GetItemActiveWorkflows(listItem);
                if (workflows.Count > 0)
                {
                    return;
                }
                manager.StartWorkflow(listItem, workflow, string.Empty, true);
            });
        }
share|improve this answer
add comment

Is this currently a Visual Studio workflow, or a SP Designer workflow? Also, is this SP2010 or 2007? If it's SPD, and you're on 2010, you can now wrap your actions in an Elevated block directly in Designer.

If you're already in Visual Studio, you can follow Ybbest's suggestion and run the code with Elevated Privileges.

share|improve this answer
    
It's actually a Nintex workflow. We're using 2010. The problem with that solution is that when the workflow is set to automatically start when an item is added and an anonymous user adds an item, the workflow starts but it doesn't run. It can then be terminated and run by an authenticated user. I've tried the run with elevated privilege in SPD and the same thing happens. –  samauger Feb 6 '12 at 22:49
    
Another option (made easy with Nintex) would be to have the workflow run on a schedule on any item in the list that's not approved. –  samauger Feb 6 '12 at 22:53
    
I've noticed the nintex worflows don't start when the user is the farm admin, try impersonating with another user. It should work –  Jaime Feb 20 '13 at 19:35
add comment

You can wrap up you code in a elevated privileges code block in your event handler.It is similar to impersonation used in asp.net.You can have a look at the following example. http://code-journey.com/2010/run-code-with-elevated-privileges-in-sharepoint/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.