Automate K2 for SharePoint deployments to another site collection


Badge +12


 

Symptoms

 


 How to automate K2 for SharePoint deployments to another site collection
 

 

Diagnoses

 


When creating a solution that consists of several list’s using the K2 for Sharepoint app, you then try to package the lists that have been created and then further try to deploy the package to another site collection on the same Web application using the K2 for Sharepoint Screens.

Is it possible to deploy this using Powershell scripts. So this will be moving all the dependencies including smart objects, forms, views etc.


 

 

Resolution

Firstly you must create a custom service broker that will generate a service instance based on your template site, and then further generate service objects for of the smart objects that have been created within K2 for Sharepoint on that specific template site.

This in turn will also add a SiteURL parameter to each method that is called here. In The service broker logic, you parse the passed value in Site URL and based on that figure out the actual system name of the smart object and which list this smo may be coming from to allow it to execute.

In broker code these properties are mapped and then further you can execute the smart object method call using the Smartobject API which in turn should return the results mapping it back.

In this case if you are looking to deploy this solution to several hundred of these site collections that this should allow you to do so.
In terms of deploying this you will need to do a couple of things on each new site collection:

1) Add the K2 App
2) Register the K2 App
3) Create SmartObjects for all the lists that should have SmartObjects
4) Change the default forms for each list

For 1: You can use SharePoint Powershell code to add the app to a site.
For 2: You will have to look at the System K2 smartform that does the registration and then further write a custom .NET Assembly that uses the SmartObject API to execute all the methods the registration form executes. This is then also called using PowerShell.
For 3: You will have to look at the system smartform that creates the SmartObjects and using PowerShell executed the SmartObject method using the SmartObject API to create the SmartObject for the list.
For 4: Again looking at the System SmartForm that changes the Default forms and we executed the SmartObject method that sets these using the SmartObject API by using PowerShell.

Now you will be able to automate this entire process and all of your sites will use the same set of forms and workflows but the data will be saved to the site where the user is actually located.

 

 



 

0 replies

Be the first to reply!

Reply