Skip to main content

My process currently has a server event that runs the following c# code to create a document library based on a custom template (K2 standard wizard does not allow for this):


SPSite mySite = new SPSite("url");
SPWeb s = mySite.OpenWeb();
                
SPListTemplateCollection listTemplates = mySite.GetCustomListTemplates(s);
SPListTemplate listTemplate = listTemplatese"CustomTemplateName"];
s.Lists.Add("libraryname", "description", listTemplate);


This works fine when K2 and SharePoint are on the same server but when they are not, I need to use the SharePoint web service 'AddList' instead. How do I do this? Do I add a web reference to the process's references and then just change my code above to reference this instead? Or is there another 'K2 way'.


Thank you.

The K2 Lists and Libraries wizard does allow you to create a new library based on a custom library template in the gallery. 


To do it in code you can add a process reference and then use a code event to set your properties and execute it.  I would suggest putting the web service URL in an environment variable and then set the web service URL to the environment/string table value in code to make it more transportable between enfironments.


 


 


Thank you David...in January I was advised you couldn't create one from a custom template which is why I used code. I have now successfully created it using the wizard. We have upgraded since then, was this feature added in a recent release? Or do I need to get glasses? Thanks again.


That feature has been in there for as long as I can remember.  But, there are a lot of options in the SharePoint wizards so it is easy to miss.  :)


Reply