views:

221

answers:

1

I have a workflow that is triggered by the creation of a list item and sends out an email when the list item is created.

If I create a new item in that list through the Sharepoint front end it sends the email.

I have a small console application designed to set the list item through the Sharepoint API. This is run as a scheduled task on a daily basis ( the purpose of the list is to nominate someone for a daily rota ) in the middle of the night. The scheduled task is run with the credentials of the Site Collection Administrator for the site.

The list item is added but the workflow is not triggered. In the log I get the following message:

Declarative workflows cannot automatically start if the triggering action was performed by System Account. Canceling workflow auto-start.

It appears as though the list item is being added by the system account rather than the user who is running the code. What do I need to do in order to have my code interact with Sharepoint using the same identity that is running the application?

+1  A: 

Consider explicitly impersonating one of your SharePoint users (in this case the site collection administrator.) I answered a similar question over here: http://stackoverflow.com/questions/2109825/updatelistitem-method-and-system-account/2111254#2111254

Once you've created a SPSite object using the context of the impersonated user all operations against that object and its children will be performed as that user.

zincorp
Excellent, I'll try that now, thank you!
glenatron

related questions