Workflow doesn’t get triggered with creating items using system account


Beware your workflow won’t get triggered when you are logged in as  system account and creating items in a list or library. Even though the association is to run the WF on item added or changed.

SO really 2 scenariosSmile

You had a bad demo when you were logged in as system account and forgot to login as user to show your shining workflow.

You are having a bad day like me awake till 3:00 AM to fix your code.  Fix your code if you are impersonating in your custom form to run as the system account.

var superUser = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
            var superToken = superUser.UserToken;

Advertisements

Tags: ,

One Comment on “Workflow doesn’t get triggered with creating items using system account”

  1. Amir January 31, 2012 at 7:48 am #

    Hi Athul
    I have great post, indeed it would save a lot of time even the above 2 scenarios are considered before demo 🙂

    However i have a question in the other direction to this post.
    How do i run my VS Code activity in an impersonated mode, i.e. not impersonated at SYSTEM account but as the user account.
    Reason for this, i want to create items in a secondary list via my primary VS workflow, and since the items are created by system Account (default due to VS Workflow) the secondary workflow on newly created items doesn’t kick start..
    how can i resolve?

    Thanks

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: