Exercise 1: Automating the Finalization of an Open XML Document
In this exercise you will create a SharePoint event handler that will automatically mark an Open XML document as finalized when its status has changed to completed. This is a common practice in the final steps of a workflow or other process that is intended to move the document through a specific lifecycle.
Task 1 – Review the DocumentFinalization project
In this task, open the DocumentFinalization project that already contains a content type, site column and document library definition. Become familiar with the structure of the solution provided as a starting point.
Task 2 – Create and Register the event receiver
In this task, you will create a new event receiver and add markup to the content type to associate the event handler you created to the existing Publication content type.
Task 3 – Open and Save the file in SharePoint
In this task, you will add code to the event handler that opens a file in SharePoint and manipulates its contents.
Task 4 – Mark the document as finalized
In this task, you will use the Open XML SDK to access the _MarkAsFinal property in the document and set it to true. If it does not exist, you will create it.
Exercise 1 Verification
In order to verify that you have correctly performed all steps of exercise 1, proceed as follows:
Test the Event Handler
Test your event handler you will need to create a new document library in the SharePoint site based on the Publication Library template. Now add a document to the document library and set its Publication Status to Published. This will cause the content type event handler to execute and mark the document as finalized.