Within K2 there are two approaches to updating document metadata. While it is common to immediately jump into the K2 event wizard “SharePoint Documents”, I want to show you today a few tricks that you can only accomplish by updating this same information via a SmartObject event.
- Be able to update/change the content type of the document after it is uploaded based on logic in my process (the SharePoint Documents wizard does not support datafield or other variable based values for the content type – the design time values you supply will take precedence)
- Allow the customer to change the column display names without affecting my K2 Processes’ functionality
- A document library with multiple content types. For my scenario there were 3 tiers of Content Types with each tier inheriting the parent’s columns and adding just a few more. This design inheritance is important because in the SmartObject event you will be picking the content type’s methods which has the most common columns. If you don’t populate those columns because you are actually using one of the base parent types, that is no problem, the event wizard doesn’t care. For instance, here is an example of the tiered content types I’m talking about:
- Document (the out of the box content type which has the basic name, title, created by etc. columns)
- ContractDocument (inherits the Document content type and adds a “Contract ID” column)
- TaskOrderDocument (inherits the Contract Document content type and adds a “Task Order ID” column)
- Task Order Modification (inherits the Task Order Document content type and adds a “Modification ID” column)
- Add a SmartObject event to your process using the Update Metadata Method from the “Task Order Modification” content type (or your most extensive / child-level content type). Even if you will really be assigning the documents content type to one of the parent types (such as “Contract Document” in my case) you can still use this method
- In my case, I use a process datafield for the “Content Type” column value in the method which allows me to only have 1 instance of the SmartObject method to support 14 possible content type values.
I spent a considerable amount of time trying to get this to work with the Document Metadata update wizard before migrating to a SmartObject event, so I hope these notes will save you some time.