Automate Site Activation in SharePoint

  • 13 August 2019
  • 0 replies
  • 13 views

Badge +7
 

Automate Site Collection Activation

 

 

 

Requirements

 
    • Dedicated site collection to build solution against
 
    • K2 App should be in the App catalog (This should already be in place with onboarding)
 

Additional Info

 

This should work both for K2 Five (on-premise) and K2 Cloud (online) as well as for both SharePoint on-premise and online in any configuration.

 

The steps below have been taken from an on-premise installation, but similar would apply for K2 Cloud and SharePoint Online. Just replace the URL of the K2 Server with the K2 Cloud KUID URL as per:

 
    • Target Site (Site collection to be activated)
   

 

 

Solution Details

 

General:

 
    • Makes use of a SharePoint List to store the Site Collection URL to be activated, the K2 Server URL and the status of activation.
 
    • The workflow should use SharePoint Events, this will the workflow to be automatically started when a new entry is added to the list.
 
    • If you use a K2 form this will be much harder to auto populate.
 
    • You can add the Site Collection entry manually to the “Manage App Deployments” section in the K2 for SharePoint App but shouldn’t be necessary. This step cannot be automated because there will be a Trust Consent loop but from my test this will not be needed, the app will be automatically deployed to the site collections as they use the same app catalog.

      11074i8EF504B328726697.png
       
 
    • You will need to use a SharePoint List Template and have the SharePoint List already created. Here I’ve created it with the name “Automate Activation List”:

      16565i5F93F5D0620F18EA.png
       
 
    • From this List, in the Ribbon bar, you must click the “K2 Application” button and select “Data” + “Workflow”. If you use K2 Forms, this will be much harder to auto populate. Make sure you select “When the following events occur” and put a checkbox in “An item was added” so the Workflow will start when a new item has been added to the List, as per:

      12285iD5670F5BB9DE6FBD.png
       
 
    • In the workflow, under “Basic”, drag and drop a “SmartObject Method” into the canvas:

      13113i583ACF0D805318A0.png
       
 
    • Edit the SmartObject Method and from the drop-down to select a SmartObject, choose “Browse”:

      10788i10B8E7D45CF50F32.png
       
 
    • Browse to the category “System” > “SharePoint 2013 Integration” > Choose the SmartObject “SharePoint Integration Helper Methods”:

      17037iD076C56540D287D7.png
       
 
    • For the Method choose “Ensure Site Collection Info” then drag and drop the existing reference for “Target Site URL” into the “Site Collection” required property field. Finally, select “Do not map outputs” for the output mappings:

      13272i058A355B6D09E6D8.png
       
 
    • Drag and drop a new “SmartObject Method” into the canvas, link it with a line, choose the same SmartObject as before – “SharePoint Integration Helper Methods” – but for the method this time choose “Activate Site Collection”. Configure the properties as in the screenshot:

      Application Site > K2 Application URL
      SiteURL > Target Site URL
      K2 Server URL > K2 Server URL
      SmartForms Runtime URL > SmartForms Runtime URL
      Management SmartObjects Only > False

      13737i0F55D401A23D23B1.png
       
 
    • For the Output Mappings, choose “Map to Variables” and create a new Variable / Data Field called “ResultOutput” and map that to the “Result”:

      11855i5BC15C0228C56655.png
       
 
    • Drag and drop a new Event into the canvas under “SharePoint > List Items > Update List Item”:

      16774i3D90B5C5FDDA3830.png
       
 
    • Choose “Pick List Item” and choose the current list from the drop-down “Automate Activation List”. Then in the Properties, add a new property and choose “Result”. Drag and drop the previously created variable “ResultOutput” into the “Result” property:

      11281i1E7D8D0B63093D32.png
       
 
    • Save and deploy the workflow.
       
 
    • Exit the Workflow Editor by clicking on “Close” and going back to the SharePoint List.
       
 
    • Go to your App Catalog and open the K2 for SharePoint App. In the URL, copy the first part until “K2forSharePoint” and paste that into Notepad:

      11148iD21338972502AC6E.png
       
 
    • Go to the Site Collection where you want to activate the K2 for SharePoint App and copy the Site Collection URL:

      11636i6A0A8AF33785DB38.png
       
 
    • Go back to your “Automate Activation List” and paste the values into the fields where applicable:
       
        1. Title – can be any title you want.
       
        1. Target Site URL – the URL of the Site Collection you want to activate.
       
        1. Result – leave blank.
       
        1. SmartForms Runtime URL – this is the SmartForms Runtime URL that you can find in your K2 Management site.
          For K2 Cloud it will use your KUID, e.g. https://KUID.onk2.com/Runtime/Runtime

          12370i7A8F0DC07CB8337A.png
           
       
        1. K2 Server URL – this is the same as the SmartForms Runtime URL minus the /runtime/runtime part at the end (could in theory be automatically created in the workflow).
          For K2 Cloud it will use your KUID, e.g. https://KUID.onk2.com
       
        1. K2 Application URL – this is the URL you copied earlier from the K2 for SharePoint App in the App Catalog site.
           

       
 

14293iBE2297B954A607AB.png
 

 
    • After creating the entry in the SharePoint List “Automate Activation List”, it should look something like this:

      15140iC881DE5091AF6CFB.png
       
 
    • This should start a new instance of the workflow you deployed earlier, you can have a look if this is the case by going to K2 Management and checking the workflow instances. Also keep a look out if this runs into an error for some reason:

      12130iEBA25D5196FAB1CB.png
       
 
    • After the workflow is complete, it should have updated the List Item “Result” with “Success”. You can refresh the List and see this clearly:

      15269iA49B7A2416C6CE0B.png
       
 
    • If this has been done, you can confirm this by going back to the App Catalog site, opening the K2 for SharePoint App, then choose “Manage App Activations” and seeing if the entry has been added to the list:

      15424i6F324C699EDF8F75.png
       
 
    • Your Site Collection should be activated now, and you should be able to interact with it through SmartObjects.
 

 

 

You can find the "Automate Activation List.stp" Site Template attached to this article as well.

 

 

 

I've also recorded a quick video to explain this issue, please see below:

 

 

 

 


0 replies

Be the first to reply!

Reply