Triggering a K2 Workflow from Microsoft Flow.

In this Post we shall see how we can trigger a K2 workflow from a Microsoft flow.

We have 2 ways to do this.

  • Using the K2 connector.
  • Using the OOB K2 Api.

Using the K2 connector

  • Go to Microsoft flow Dashboard and click on “New” and you will see few options among which you need to select “Instant – from blank”.
  • Give your flow a name and there you will find different options to trigger this flow. Here I have selected “Manually trigger a flow”.
  • Once the flow designer opens, Click on New Step in the search box and type K2 which will show you the K2 related connectors. Select the K2 Workflow connector as shown in below.
  • Select Start Workflow from the list shown.
  • Next provide the details of your workflow, you can pass either Workflow Id or workflow name here or you can select from the list.

Now create a new connection by clicking on dots and select New Connection

Enter data and click create which will create a new K2 connection and use it for this step.

** This Connector that we are using here is a preview K2 Connector version which uses a single user account credentials which we need to use only for development Purpose. But in general UAT and production environment we have to create a Custom Connector which uses Oauth to authenticate.

To Know about Creating K2 Custom Connector please visit the link below

  • Once you select the workflow it will provide options to pass folio, data fields  and some advanced options as shown in below screengrab
  • Click on Save and then Click on Test and Select I’ll Perform the trigger Action
  • Once flow Started Successfully, we can go “My Flows” and tab and select the flow that we have created and click on dots Symbol and select Run history to see the status of the flow instance that we have started.

Here the Flow instance status shows as Test Succeeded which means the flow has run successfully and it should have created an instance in K2. Let’s go to K2 Management Site and see if it has created an instance.

You can see the instance has been created successfully. Let’s see the other approach using K2 api.

Using the OOB K2 Api.

  • Enable K2 REST Api from K2 Management (Use below link to know how)

  • Once enabled check whether they are configured properly or not by running below url in post man or directly in chrome browser.


If we see the data then we are good to go.

  • Go to Microsoft flow designer -> navigate to my flows – > select the flow that we created before -> click edit -> add new step -> Search for HTTP and select.
  • Enter the Requests details as shown in below.

You can know the Workflow Id of your process from the “Process” smartobject which will be under category System/Management/Workflows/Smartobjects

  • Set the Headers Content-Type as Application/Json.
  • In Body we can set the Folio and data fields as shown.
  • Authentication we can user Basic/OAuth. Here I’m using Basic for Development purpose but generally we have to set it to OAuth. To know how to set OAuth for Api please refer below link

Save the flow and test run to see the result.

**Similarly we can follow the same approach performing a task action and other K2 Activities.

That’s it. This is how we can trigger a K2 workflow from Microsoft flow. Thanks for Reading!!

Sharepoint List Binding with K2 Workflow & Smartforms

Today we shall see how we can bind a K2 workflow with a Sharepoint List and trigger the workflow when an item gets added to the list. Also we shall see how we can use K2 smartforms for adding & updating an items in SharePoint list.

In previous post I have shown how to enable K2 for a list using K2 Five for Sharepoint tool and the options for generating the Smartobjects, Smartforms, workflows & Reports for the list. Now we look at the other way to achieve the same.  I’ll be using the Same Users SharePoint list which I have shown in previous post

Click on K2 tab and select application which will open the page as shown below

As we have selected only Smartobjects generation in previous post, it is just showing them. Now Click on New tab and Select Generate Forms which will show you below screen.

Now click OK and the tool will generate view and forms for you based on the list columns and once it completes it will show you below screen with all the views and forms that are automatically created.

It will create 3 forms one for adding a new item, one for editing and one for display purpose. We can directly edit the form or view from here if you want to change anything like look and feel or controls. Also you can edit these forms from the K2 Designer which I have shown in my previous post.

Click on Settings to see or change the forms to show.

Now navigate to Users List and click on new to see the K2 Form which is highlighted in below screen.

Now let’s create a new workflow and associate with this list, so that whenever a new user is added to this list it will create an approval task to some user and updates the status accordingly.

Now from the Users List K2 Application screen, click on New and select workflow.

Now it will show you below screen where you find 2 options to trigger the workflow. One is via Smart form submit button and the second way is via Sharepoint list item events that are available and shown there.

Here I’ll select “When the following events occur” and select “An item was added” and select OK which will open K2 workflow Designer. Now design your workflow with your requirements.

In Users List I have added a new column called Status and initially when a new User is added to the list, the status will be Pending Approval and once the task is assigned to Manager and he performs as an action then accordingly the status will be updated and workflow will complete.

Below is the screen shot of workflow that is created for this purpose. I’ll create a separate post explaining the process of creating a workflow in new designer with all the events that we have now.

Now Create a New User in List and see the Workflow is getting Triggered status will be set as Pending Approval

And task is getting assigned in TaskList (You can access Tasklist from K2 Tab in Users List.)

Approve the task and see the status getting changed.

That’s it. This is how we can make use of K2 Smartforms and Workflows along with Sharepoint list.

Thanks for reading!!

Registering a SharePoint Service Instance Using K2 Five for SharePoint App.

Prior K2 Versions have the provision of creating a Sharepoint Service Instance from the “SmartObjects Service Tester Utility” Tool by providing the Site URL, which would fetch all the objects in that site. But the latest K2 Version (from K2 Five I believe) they have removed the direct provision to create a new Sharepoint 2013 Service Instance and it has to be created Via K2 Five for Sharepoint App. Let’s See how we can do that below.

Below is a custom SharePoint site which has a List “Users”.

  1. Before we add K2 App to a site, Pre –requisite is to install K2 Five for Sharepoint on site collection level. Only then it will be available as an app for all sites.
  2. Once the installation in done now Navigate to the Users List and click on Settings and Click Add an app and select K2 Five for SharePoint in it. This will activate this app on this site.
  • If Pop-up is shown like below Just Click Trust It and then it will start activating this app to this site. To perform this step User needs admin permissions over the Sharepoint Site collection. Also it asks for SharePoint Admin URL Details.
  • Once the process above completes it will show the status as Activated.
  • Next step is to navigate to Users List and see if K2 is shown in top navigation bar as shown in below screengrab. If you see the K2 as shown below then we are good to go with generating the Service Instance & SmartObjects.
  • Now click on Application and it will take you to a new tab as shown below.

This is the screen from where we can generate SmartObjects for the Users List, In case if you want to generate forms & workflows along with reports, which you want to use along with this list then you can check the other checkboxes. I will explain these options in a separate post but for now I’ll create just SmartObjects.

  • Now click Ok and the app automatically creates the Service Instances and SmartObjects for us. Once done it will show 2 SmartObjects as shown below. One for the List & the other for List’s Attachments.
  • We can see these SmartObjects in K2 designer as well as SmartObjects Service Tester Utility As well. In designer we can see these SmartObjects under Sharepoint 2013 Category.

  • If you want to edit this Smart Object we can directly edit in SharePoint itself by clicking on Edit in SharePoint K2 App or Navigate to path above in K2 designer and edit.
  • SmartObject Methods that are created by default are as shown in below screen shot
  • Select GetListItems and Execute to see the SharePoint List Data.

That’s it. This is how we can generate the Sharepoint SmartObjects using the Sharepoint App.

In my next post i will show you how to use K2 smartforms for Adding and editing a Sharepoint List Item with in Sharepoint Context.

Thanks for Reading.

Refer for More Information

Moving to K2 Five? – Things to know as a Developer 

Hello Friends, It’s been a long time since I have posted a new update in my blog as I couldn’t get time due to a big leap in my career and was busy trying to learn too many new things.

Now that I got a chance to work on K2 5, I would like to share the things and major changes that I have found while moving from K2 4.7 to K2 5 which would definitely help you guys who are planning to start their work in K2 5. Below are the things that I can highlight and we shall go through them in details one by one.

  1. No Visual Studio, No K2 Studio. Both of these workflow development tools have been removed in K2 5. Now we have a fresh and revamped New K2 Designer which is completely changed and gives a great UI experience which we have to use for developing everything in K2 i.e. Workflows, Smartobjects, Smartforms.

New K2 Designer

It will show the most recent files that you have accessed along with folders.

Also you have links to K2 tutorials for learning these new things.

K2 Five Designer New Look

Sneak Peek of New Workflow Designer

Workflow Designer Sneak Peek

In my next post I’ll explain with a sample process to create a new workflow, smartform, Smartobject in detail covering all the options and the changes in the naming conventions and more.

  • Workflows that are migrated from 4.7 to K2 Five can still use Visual Studio to modify the workflows but if we you want use new designer for old workflow then you have to recreate them.
  • We have new Workspace with complete new UI and most of the features getting changed.

Here we do see a complete new look as shown below

Inbox will have all K2 Task Mails that you receive as part of Task Notifications once open the task it will load the related form or if no form is configured for that task then it will open default basic task form as shown below.

Along with this new Inbox Feature we still have our old Process Overview Reports where we can see the activity instance data of all process instances along with Audit data of data fields.

All process details are listed below click on the link to go to the particular process instances. All similar to old process overview but just the new look. Below is the screen shot of a particular Process instance details. You just need click on instance to see the details.

  • Along with this we have the same K2 Management site which got introduced in 4.7 getting used here too.  Screen Shot below

As you may already aware that this Management Site can be used to manage all admin kind of activities like

  • Managing permissions
  • Providing access rights
  • Export rights
  • Role Management
  • Testing Smartobjects
  • Error Logs
  • Out of office configurations and many more.

I’ll create a detailed post about this in coming days.

  • Package and Deployment tool is still the same as old tool.

That’s it for this post. I’ll create separate posts in detail for all the topics that I’ve mentioned above and publish here soon.

Thanks for Reading!!

How to Show Checkboxes in a Readonly ListView and Select the row on click of Checkbox


Hello Friends,

It’s been quite a while since I have created a new post as I was not getting time to do so.

Recently one of my friend approached me for a typical requirement in which he need to show a checkbox in a Read-only List view and then user check’s those check boxes to select rows which could be multiple at a time, Generally K2 smartforms doesn’t show checkboxes in read-only mode of  a list view. We know that we can select multiple rows using control + Mouse click on the row, but client was not happy with that approach and he insisted to use checkbox option in the grid.

Let’s see how we can do that.

Step 1: In the list view create a new column and drag a datalabel control into it. Check the Literal property and in Expression click on ellipse button, click add and then give expression a name and paste below script in it and click ok.

<input type="checkbox" />


Step 2: Create a new data label with name dlHighlightRow and drag on the layout and set visible to false. Now in layout click expression Symbol   click add and create new expression with name Highlight and paste below code in it and save.

 $('input[type="checkbox"]').each(function(index, item) {       
 if ($(this)[0].checked) {           
   $(this).closest('tr').addClass('highlighted selected');       
  } else {           
   $(this).closest('tr').removeClass('highlighted selected');       

Similarly add one more expression with below script and name it as NoScript


** Don’t forget to add script tags in starting and ending of jquery code, Here in post they are getting removed by default.  script

Step 3: Now in list view item click rule add below rules to set the expression value to data label dlHighlightRow first with Highlight Expression and second with NoScript Expression. Also set literal property to . This way we are dynamically injecting the script into the form also for each item click we are making it run.


Now you can use the rule For all Selected rows of the lisView to get the selected rows. That’s it, now save the view and run it see the Jquery Magic 😊 Note: The Highlight Expression that we created above has the main logic of looping through the checkboxes and see if it is selected and make the row selected. This script may not function properly if your view has more checkboxes other than that of in first column. If you have so, then we need to add a class in checkbox expression as below

<input type="checkbox" class="gridCities-CheckBox"/>

And Highlight expression we need to modify the code as

 $('.gridCities-CheckBox').each(function(index, item) {       
  if ($(this)[0].checked) {           
   $(this).closest('tr').addClass('highlighted selected');  
  } else {           
   $(this).closest('tr').removeClass('highlighted selected'); 

Also, there is another approach to achieve this which can be found at below article.

Note : In the approach explained in above article, list item click event & list item double click events will be disabled.


What are K2 Composite Smart Objects and how to create them.

K2 have provided a great feature to join data from multiple data sources into single dataset. If your application has data coming from multiple lob’s like SQL, Sharepoint, WCF Services, REST Services etc and you need to combine the data and show them as single dataset then composite smart objects are perfect pick for you. They are like Joins in SQL, but the data sources can be different.
Let’s see how we can create with an example.
**Before moving further, I would like to mention you that Composite SmartObjects can be created either in VisualStudio or K2 Studio. (In K2 Designer we can’t, not until K2 Version 4.7 as I know).
Coming to example, I have Departments data (Department ID, DepartmentName) in K2 SmartBox
and Employees data in SQL Server


Now we shall join the above data by creating a composite smartobject and execute it to see the result.
Step 1: Open Visualstudio, Create New K2 Empty project give it a name and in solution explorer right click add new smartobject and give it a name here it is (Employees) and click ok. Now at the top of window click AdvancedMode, under SmartObjectMethods click remove all and click ok


Step 2: Under SmartObject Methods, click on Add, Select AdvancedMode Checkbox and click next, provide a name and select list in Type Dropdown and click Next, Now in method parameters window click next as we can add parameters later while configuring,
Step 3: Now in ServiceObjectMethods window click Add and select the dbo.Employees table List method from the context browser under the SQL Server Service Instance

Now Map the properties or simply click Create All to auto map the properties. Once done you should see below window

Click Ok and you should see the ServiceObjectMethod Window
Step 4: Again, Click Add and repeat the same steps for Departments.List which will be under K2 Smartbox Service instance once done click Ok

Step 5: Now we are at Service Method Link Window which is the main step of this SmartObject Creation. Here in first Dropdown select the Employees SQL Service Instance Method and in Link Type Dropdown select Matching Values in both objects and in 3rd dropdown select the Departments Smartbox Service method and in properties below, select DepartmentId and click assign and from the dropdown select DepartmentId and click ok.
Now we have joined SQL Server Employees Data with Smartbox Departments data using DepartmentId which is the common column in both data.
Link Type is kind of Join type as in SQL server. Here we have 4 different options of link types

1. Matching Values in both objects (similar to SQL Inner Join)
2. All Values for first object (Left Join)
3. All Values for Second object (Right Join)
4. All values for both objects (Outer Join)

Step 6: Just click ok and you are good to deploy and run the smartobject to see the results.