Wednesday, August 13, 2014

Internal details of Document ID feature activation or why Document ID is not added to content type after feature activation – Part 2

This is the 2nd part of series about internal details of Document ID activation, part 1 is here. We finished on the fact that you need to wait at least 0,5h or change system time before to run “Document ID enable/disable” job. Let’s continue investigation and will check what happens after that.

After activation of “Document ID Service” feature, Document ID settings page becomes available in Site settings page. After feature activation it will look like this:

image_thumb[7]

As mentioned in part 1 now we will temporary change system time: add 1 hour to the current time and reset Sharepoint Timer service. After that go to CA > Monitoring > Job definitions > “Document ID enable/disable” job (for appropriate web application) and click Run now. If you will click on Running jobs after that you should see progress bar for "Document ID enable/disable" job (if you would run it before time specified in DeliveryDate column you would only see in Jobs history that "Document ID enable/disable job" ran 00:00:00, i.e. exited immediately after started):

image_thumb[9]

If you will execute the same Sql query which we used in part 1 after job will be finished it should not return any rows:

   1: declare @enable uniqueidentifier
   2: set @enable = cast('749FED41-4F86-4277-8ECE-289FBF18884F' as uniqueidentifier)
   3: select * from [dbo].[ScheduledWorkItems] where [Type] = @enable

At this moment if you will check Document ID settings page it will look like this:

image

I.e. now it will have value in "Begin IDs with the following characters" field. But also it shows the warning:

Configuration of the Document ID feature is scheduled to be completed by an automated process.

It means that feature activation still not finished. It happens because “Document ID enable/disable” job creates another work item with type A83644F5-78DB-4F95-9A9D-25238862048C. In order to check it execute the following Sql query:

   1: declare @assign uniqueidentifier
   2: set @assign = cast('A83644F5-78DB-4F95-9A9D-25238862048C' as uniqueidentifier)
   3: select * from [dbo].[ScheduledWorkItems] where [Type] = @assign

image

It runs with the following params which is specified in TextPayload column of ScheduledWorkItems table:

   1: <?xml version="1.0" encoding="utf-16"?>
   2: <DocIdWorkitem
   3: xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   4: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   5:   <fOverwriteExisting>false</fOverwriteExisting>
   6:   <Cookie>1</Cookie>
   7: </DocIdWorkitem>

This work item is processed by "Document ID assignment" job. This item is added by "Document ID enable/disable" job and sets values in Document ID field for all existing documents on the site. Here we also should pay attention on value in DeliveryDate column. It should be near the time when you forced "Document ID enable/disable" job on previous step. As we didn't change time back yet in order to execute this work item just force it in Central administration. You should see "Document ID assignment" job progress in Running jobs:

image


and after some time work item should be removed from ScheduledWorkItems table (you can check it by running Sql query shown above).

After that you may change system time back and reset Sharepoint Timer service. If you will now go to Site settings > Document ID settings it should not show red warning text anymore.

But "Begin IDs with the following characters" field will still contain the same random string:

image

If you need to change Document ID prefix to your own value, you will need to go through whole process again. After you will click Ok work item with type 749FED41-4F86-4277-8ECE-289FBF18884F with the following parameters:

   1: <?xml version="1.0" encoding="utf-16"?>
   2: <DocIdEnableWorkitem
   3: xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   4: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   5:   <fEnable>true</fEnable>
   6:   <fScheduleAssignment>true</fScheduleAssignment>
   7:   <fOverwriteExisting>false</fOverwriteExisting>
   8:   <fDocsetCtUpdateOnly>false</fDocsetCtUpdateOnly>
   9:   <prefix>TEST</prefix>
  10: </DocIdEnableWorkitem>

(In this example TEST prefix is used). And work item with type A83644F5-78DB-4F95-9A9D-25238862048C and params:

   1: <?xml version="1.0" encoding="utf-16"?>
   2: <DocIdWorkitem
   3: xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   4: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   5:   <fOverwriteExisting>false</fOverwriteExisting>
   6:   <Cookie>2</Cookie>
   7: </DocIdWorkitem>

After both jobs will be finished, add some document into document library. When you will click View properties, to should see Document ID field – link with text “TEST-1-1” which points to http://example.com/_layouts/15/DocIdRedir.aspx?ID=TEST-1-1 url:

image

I.e. now you can use OTB Document ID field in document content types. This is the end of the series. Hope that this information will help you in the work.

No comments:

Post a Comment