tags:

views:

232

answers:

2

Hi

I've developed a Help Desk application in Visual Studio that uses a Sharepoint List to store the data.

My problem is that when i use the UpdateListItems method for submitting a new record, Sharepoint automatically assigns to the "Created By" (Author) field as "System Account" and this prevents the trigger of a workfow i created with Sharepoint Designer. I've tried to force the Created By field during submit by adding to my batch person id;#person username

but it will still show "System Account"!!

Any ideas!?

sorry for my bad english:(

A: 

Option 1: "Update the workflow"

I would not recommend trying to change the Created By field. Instead, create a new People field (named Submitter or something) in your list and populate that with the user. The workflow should use the Submitter field instead of Created By.

Option 2: "Update your code"

If your workflow, can't be updated, then you'll have to change your code. Instead of submitting using the Service Account, you will need to submit using the credentials of the current user. This means that they will need to have the correct permissions to the list. I am not sure if your code is in a web part or not, so I can't really be more specific.

Kit Menke
+1  A: 

Have you considered using impersonation to update the list item?

You need a user on the site who has the correct access that you can impersonate. Look into the SPSite constructor that gets passed in an SPUserToken.

SPUserToken token = targetWeb.AllUsers["BobTheImpersonationAccount"].UserToken;
using(SPSite impersonatedSite = new SPSite("http://siteurl", token))
{
    //Anything accessed through impersonatedSite and its child objects are now executing under the guise of BobTheImpersonationAccount

}
zincorp
i've got to use microsoft.sharepoint namespace instead of the Web Service so i've got to do some changes to my code but this done it!! ...thank u zincorp!
nego