Generating documents from workflow systems is common. In fact, record generation in the form of a digital document is a common output of a K2 workflow. For example, if a service plan is approved in a workflow, a version of the plan is generated using data stored in a database and pushed into SharePoint for storage.
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
Data in K2 is exposed using K2 SmartObjects. These are unbelievable flexible objects that allow data access to virtually any data source. This means we can inject data from lost of different locations in something like a Word document. This blog step through this process and explains how to generate Word documents using K2 blackpearl and SmartObjects. In this instance I will show how to generate a document that lists all the users that are part of some departments.
The first step is to have a data source. In this instance I will use a SmartObject that lists users in Active Directory that is part of the several departments.
Next, create a Word template that has a table with columns for each of the users’ properties (e.g. User Name, Display Name, etc.). Each of the columns in the table is populated with a text control from the Developer ribbon. The key is to copy the SmartObject name in the Title textbox and the SmartObject properties in the Tag textbox.
The next part of the process is to create a OpenXml writer that maps the SmartObject Method and Properties to the controls in the document template. Some company propriety code is in this component, but the general idea is to create client code that provides inputs to the mapping method. This give you an idea how such a component can be created
The implementation also supports colour coding cells in the table based on data inserted into the cell. The results are as follows –
From a design perspective, the code above is typically included in a K2 Document Generation Service Object. This means you can generate a Word document from a K2 SmartForm by calling a K2 SmartObject wired into the K2 Service Object
About Velocity IT
We are K2 Masters. We are at the cutting edge of K2 workflow, K2 blackpeal and K2 SmartForm development. Our projects are changing the way people work across various industries. For more information, please visit our Velocity IT homepage.