Monday, August 28, 2017

Different ways to create smartobjects from SQL service instance

I asked the question to k2 support, What is the difference between Create and generate smartobject? and they provided below answer, thought would be helpful to share.

There are three different options available to create/manage SmartObject from a SQL Service Instance via SmartObject Service Tester tool:

a.  From service instance > Create SmartObjects
- manages the creation and updates of all SQL SmartObjects of the service instance as well as SmartObject's category as a set (no control over displayname and guid)
- allows for the appending of a string to all of the SmartObject system name (no control over the overall displayname, systemname, guid)
- can be used to update all SmartObject as a set if there are changes to the database objects schema(tables, views, sprocs)
- displayname, systemname and guid will remain the same (if targeting the same set of SmartObject)

b.  From service instance > Generate SmartObjects
- manages the creation and updates of all SQL SmartObjects of the service instance as a set (no control over displayname, systemname, category, guid)
- can be used to update all SmartObject as a set if there are changes to the database objects schema (tables, views, sprocs)
- displayname, systemname and guid will remain the same

c.  From Service Object > Create SmartObject (singular)
- allows for managing of the SystemName/DisplayName, GUID, and category SmartObject is created in
- can be used to regenerate/update the existing SmartObject by targeting the 'SystemName' of the SmartObject (with the 'Check Name' button) and returning the current GUID for this SmartObject (with the 'Get Existing Guid' button) before publishing it again
** if not returning the existing name and GUID, a new SmartObject with different value will be created

* all three options mainly used if there are NO customization with the SmartObject and the default generated functionality is desired; as regenerating the SmartObject with the same SystemName and GUID will remove any customization previously done; if SmartObject was customized, manually changes to these objects in the designer that they were designed in (K2 Designer, K2 Studio, K2 for Visual Studio) will preserve the customization.

Friday, July 22, 2016

K2 Interview Questions: Workspace, Part 1 (Intermidiate)

All K2 Interview Questions

What are Worklist Item/task statuses?
0 = Available
The item has not been opened yet
1 = Open
The item was previously opened by the current user
2 = Allocated
The item was opened by another user
3 = Sleep
The item was set to sleep for a specified amount of time
4 = Completed
The item was already completed by this or another user
In a majority of cases, once a user has opened the task, the task status is Open for that user and Allocated for everyone else.

Wednesday, July 13, 2016

K2 Interview Questions: Workflows, Part 2 (Advance)

How do you fix the process in errors?
1. Sometimes the error is because of network issues, some connection problem or no proper inputs. If you just go to the error profile in the workspace and retry the error it fixes the problem.
2. If above approach does not resolve the error you can use the K2 Process Management tool in Visual Studio.
 As shown in the figure below. you can select process clicking View->K2 Process Management tool in visual studio. Select the process in error and open the process and fix the error.

After fixing the error, go back to the k2 process management and click redeploy the process.

You can provide the label and deploy the process. It will fix that instance of the process. Then you can fix the processes with similar error hitting the retry button and selecting the fixed version of the process.

How do you debug the process if  the Visual studio is not installed on the K2 box?

Thursday, July 7, 2016

K2 Interview Questions: Workflows, Part 1 (Advance)

What is IPC event wizard?
  • The IPC (The Inter Process Communication) event wizard is normally used to implement a Parent-Child workflow or sub-workflow requirement.
  • Also it is useful when you want to split a larger workflow into sub-processes, when you have processes that are generically re-usable, or when you want to start multiple instances of a child workflow from a parent workflow.
  • You can use it to set Folio, Originator, and data field values for a Child workflow as part of the wizard.
  • There are two options while configuring the call to the child process
    Synchronous: Parent workflow waits for Child workflow to complete.
    Asynchronous: 'fire-and-forget' style, in which the Parent workflow continues immediately after starting the Child workflow.
  • Use advanced destination rules (Plan per Slot, No Destinations) to allow one Parent workflow to start multiple Children
What are different activity planning options in Advance destination rule? and explain them.
There are three main Activity Planning options: Plan Just Once, Plan Per Destination, and Plan Per Slot.

           Plan Just Once : 
  • This default option. K2 will execute the events in the Activity prior to the Client Event just one time, regardless of how many destinations or slots have been defined. The events after the Client event will be executed each time a user completes a task. This is the default behavior for Activities.
  • This option is most appropriate for high-volume scenarios where a large group gets the task but only one user will ever need to open the task.
  • When this option is selected, there is only one activity instance, which is shared amongst all destinations for the task.

    Plan per destination:
  • This approach is most often used when more than one person will open the task, and you need to capture input from each user into the same activity datafields.
  • K2 creates separate copies of the Activity Instance for each destination

    Plan per destination – All at Once :
  • K2 will execute the events in the activity for each destination in the activity in parallel fashion. Each event in the activity is repeated for each destination, and then K2 moves on to the next event in the activity and repeats that event for each destination.
  • This planning option specifies that all destinations will get the task at the same time (Parallel). Any one of the destination users can open the task and complete it. If any of the outcomes are true for the activity, the other copies of the task are removed from the other user’s task lists, and K2 completes the activity.
  • Plan per destination – One at a Time : K2 will execute the events in the activity for each destination in the activity in serial fashion. K2 starts with the first destination and executes the Events in the activity once for that destination. If the Outcome is false, K2 moves on to the second destination and then executes the events in sequence for the second destination. This is repeated for each destination in the activity until the Outcome succeeds or no more destinations are available.

    Plan per slot – (no destinations)
  • This setting is normally used for activities that only contain server events when you want to repeat the events in the activity N-number of times for each slot in the activity. 
  • It is similar to the Plan Per Destination – All at Once setting except that K2 does not use the Destinations to determine how many times to execute the events but rather the number of slots specified on the next page of the Destination Rule wizard.
What is use of Update Design Templates in K2 visual studio workflows?
The purpose of this tool is to apply enhanced code templates when you have upgraded your K2 environment to a newer version of the platform.The Update Design Templates command in the K2 design tools will wipe out any customizations you may have applied because it restores the original templates for all items and will undo any customization.

What event is use to write a code in workflow?
Default server event wizard is used to write a code in workflow. It is only available in K2 for Visual studio.

How can be method be called from custom assembly or service?
There are alternative approaches to using code in your workflows: 
1. You can add reference to the assembly and call method in a class adding using namespace reference in default server code event
2. You can use the Code Reference Event to call methods for referenced assemblies and services.
When a workflow must interact with a system that is not exposed as a K2 SmartObject, but you do not wish to write code, the code reference event comes to the rescue. This event can be used to call methods on web services (asmx), WCF services and assemblies (.NET and COM dll’s).
3. If you need to call the same assembly/Service multiple times, it is recommended to expose that assembly/Service as a SmartObject.
  • By using one of the available EndPoint Service Brokers,
  • By writing a custom Broker that exposes the necessary functions. This will allow you (and other designers) to call the methods in the Service/Assembly easily without having to write code.

What is Asynchronous server event?
Asynchronous Server Events are used when you want the server event to wait for an external system to call back. The external system will use a serial number to complete the task and tell the K2 server event to continue.

What are the different places in workflow you can enable and handle exception?
You can handle the exception at event, activity, line, escalation rule, escalation action and at process level

All K2 Interview Questions

K2 Interview Questions : K2 extensions/API, Part 1

Scenarios where K2 Workflow Client API (SourceCode.Workflow.Client.dll) can be used.
The workflow Client API refers to the .NET assembly SourceCode.Workflow.Client.dll. This assembly exposes several classes and methods that are used by developers when interacting programmatically with a deployed workflow.

In practice, the SourceCode.Workflow.Client assembly is often used to create custom task lists, to start workflows or complete workflow tasks (known as worklist items) from custom user interfaces like ASP.NET web pages, and to create alternative interfaces or tools to allow users to maintain their out-of-office status and worklist items. The workflow client is also often used to create automated testing code or applications that are executed against a workflow definition to verify that the workflow is behaving as expected.

Scenarios where K2 Workflow Management API is used.
The workflow Management API refers to the .NET assembly SourceCode.Workflow.Management.dll. This assembly exposes several classes and methods that are used to administer K2 workflows and the K2 environment. Essentially, this API allows developers to perform similar administration functions as the ones exposed on the K2 workspace and K2 process portals’ Management console pages. The Workflow.Management API is not exposed as a WCF or Web service: it is only available as a .NET .dll
In practice, the SourceCode.Workflow.Management assembly is often used to manage processes, automate Error reporting and Error repair, to manage other users’ worklist items and Out-of-Office statuses, to manage active process instances and perform workflow version migration for in-flight workflows.

K2 Interview Questions


Part 1 (Beginner)
When NOT to use SmartObjects?
What are the Common uses for SmartObjects?
What are the standard K2 service broker/Connectors to LOBs?

Part 1 (Intermediate)
What are Worklist Item/task statuses?

K2 Extensions/API
Part 1 (Adv)

K2 Workflows
Part 1 (Adv)
Scenarios where K2 Workflow Client API (SourceCode.Workflow.Client.dll) can be used.
Scenarios where K2 Workflow Management API is used.
Part 2 (Adv)
How do you fix the process in errors?
How do you debug the process if  the Visual studio is not installed on the K2 box?

Thursday, June 30, 2016

For each loop processes half of the items in K2 workflow.

In my scenario, I have SharePoint list hooked up with smartobject. SharePoint list has flag column (Yes/No), default to No.

For each loop is set to retrieve all the items from the smartobject with the query like, Select ID column from SharePoint list where flag=no.

Then, doing some operation on list item fetched with ID and then updating the flag to Yes, indicating done with that item in a list.

Updating the flag to yes, loop only retrieves alternate or odd items in a list (basically, it processes only half of times in the list).
Without update operation, it works fine.


Decreasing the index of the for-each loop after the for-each event loop processes all the items.