K2 BLACKPEARL PRODUCT DOCUMENTATION: USER GUIDE
Process Start Rule

K2 Designer for Visual Studio 2012 - Process Start Rule

The Process Start Rule can be accessed by clicking on the icon in the Process Title Bar

The Process Start Rule Wizard allows the process creator to insert custom code within the process Start Rule. The Start Rule determines the conditions under which the process will start. If the conditions are not met, the process will not start.

There are no advanced UI features and no default code. Viewing the code for the rule will present an empty XOML Windows Workflow Foundation design canvas, it is up to the process creator to create the custom code. Use a WinWF code activity by dragging it from the toolbox onto the Drop Activities Here area.

Option What it is How to use it
Enable Process Start Rule Enabling this option allows the process creator to add custom code to the Start Rule Click on the check box, then click on View Code to load the XOML screen. Insert the required code within the process Start Rule (see below)

The process Start Rule is not a required feature. If no process Start Rule is configured, no validation will be performed once the process is started and the process will continue as if the rule evaluated to True.

Editing the Custom Code

Clicking on the View Code button from the Process Start Rule wizard, will load the Start Rule XOML file.

Insert the custom code within the file by dragging the Code Activity from the WinWF toolbox and save it. Right click on the activity and select View Code to add the custom code.

Alternatively, right-click the Drop Activities Here section and select View Code to open the Start Rule class code file.

Insert the custom Start Rule code within the file and save it.

Example

In this example we used the code activity, then opened the code by double clicking on the code activity.

We then added the following code:

Copy

public partial class StartRule_56e27d9756b6483b839228b89c302d07 : IWorkflowContext<hostContext>

{

#region K2 Context

private hostContext _k2;

#endregion

#region IWorkflowContext<hostContext> Members

public Project_25f626e034434aa78505f21d614afb93.StartRuleContext_56e27d9756b6483b839228b89c302d07 K2

{

get

{

return _k2;

}

set

{

_k2 = value;

}

}

#endregion

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

bool start = true;

//Check data field to determine whether or not the process should be started:

if (K2.ProcessInstance.DataFields["Some Field"].Value == "Sales")

{

start = false;

}

K2.Start = start;

}

}

}

In this example, the process will check for the Data Field "Some Field" and if the Value is equal to "Sales", the process will be started. If the Value of the Data Field is not equal to "Sales", the process will not be started. In addition, if the Data Field cannot be found, an error will be received.   

 

 


K2 blackpearl Help 4.6.11 (4.12060.1731.0)