Skip to main content
Nintex Community Menu Bar

Modified by user in Sharepoint

  • June 29, 2009
  • 2 replies
  • 67 views

Forum|alt.badge.img+1
We have a very simple workflow that updates a status field on a Sharepoint document library when a new item is added.  Doing this causes the last modified user to be set to the K2 Service account.  Is there a workaround or any way to prevent this behavour?  It makes the product almost unusable for Sharepoint based workflows where you need K2 to update any field in a list or document library. 

2 replies

Forum|alt.badge.img+6
  • June 30, 2009

Hi,


This is the default behaviour because actually this is the account which is starting K2 that really does the update. You have 2 ways to change this behaviour.



  1. you can create a new column in your Sharepoint Lib with the login of the user you want... and you will updated these column with the value you want in your Sharepoint Event.
  2. You add impersonate code into your Sharepoint Event (I've never test this but it must work).

HTH


Forum|alt.badge.img+1
  • Author
  • June 30, 2009

After spending a day on this, I got a solution and will post it below for everyones benefit.



  • Put a Sharepoint Document event on the canvas (I suppose you can do the same on a Sharepoint List, but I didnt try)
  • In the the wizard, select "Update Document metadata" and complete the wizard as you normally would.
  • When complete with the wizard, right click on the event and view code.
  • When the WF diagram is shown, right click on it and view code.
  • Inside the .cs file, find the method for "UpdateDocumentMetaData_ExecuteCode"
  • Inside this method, find the line of code for:



resultSet +=

"</Documents>";



  • Below this line insert (where domainusername is substituted with your acutal value):



resultSet = resultSet.Replace(

"</Fields>",@"<Field><Title>Modified By</Title><Name>Editor</Name><Type>Text</Type><Value>domainusername</Value></Field></Fields>");