SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change the Document ID through code, the why is out scope for this question. I do have a reason, and I can explain this if you want, but please accept the fact that I have the need to change this using C#.

The following code works fine in a console application:

 SPFile oFile = oWebToChangeDocID.GetFile(sDestination + sFileName);
 //Change the document ID
 oFile.Item["_dlc_DocId"] = "TESTID";
 oFile.Item["_dlc_DocIdUrl"] = "http://rms2010:1001/sites/site/_layouts/DocIdRedir.aspx?ID=TESTID, TESTID";

But I need to execute this code in a custom WorkFlow activity (which I have written). When this code is executed from within this activity, however, it does not always work...

I've tried using different threads (including thread.sleep, to wait). I've also changed the code to use an asmx webservice (in this webservice I also tried threads, etc) without success.

As mentioned, this does work on some documents, but if I execute the same code (using my console application) on a document which failed using the workflow activity, it does work!

I do not understand what I am missing, any input is welcome!

Note: I use elevated permissions in both the workflow activity and the WebService.

share|improve this question
up vote 0 down vote accepted

Alright, I've not fixed this issue yet, tho I have found out what the problem is:

I figured out that this Workflow Activity is working when the SPListItem had the _dlc_DocIdPersistID property set to "1". When the SPListItem does not contain this property, this WF activity fails.

So I decided to put a breakpoint in my custom document ID provider, and IDD the breakpoint only gets hit on the files that DONT work. And in this custom provider, an exception was throws which locked the "document ID".

That's why I could not change this for this documents.

So we need to adapt the document ID provider to fix this issue.

Since this has nothing to do with the original question, I consider this question closed!

share|improve this answer

Your Answer


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.