Sunday, October 16, 2011
K2 26023 Process instance n not found for domain\user at nnn.nnn.nnn.nnn
For example, you are trying to use Connection.OpenProcessInstance() on a Completed Process Instance. A big part of K2 is auditing and thus, it won't allow you to modify completed instances - that is why you have K2 right?
Even if you are using Connection.OpenProcessInstance() for Active Process Instances, you should question if you are using the right methodology. Process Instances should for the most part only be modified through the OpenWorklistItem() or OpenServerItem() mechanism.
Thursday, September 10, 2009
CheckBoxList validation with jquery
Sometimes you want to force users to make at least one selection in a CheckBoxList.
The problem is that it’s easier said than done, because the RequiredFieldValidator can’t be linked to a CheckBoxList control.
Most likely, you would prefer to do client-side validation as well, right?
I have come across many examples on the web on how to do this, but most of them fall short one way or another.
By adapting and combining the examples, I have come up with the following by using jquery:
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script type='text/javascript'>
ValidateChecked = function(oSrc, args) {
var n = $("#pnlBoxes input:checked").length;
args.IsValid = (n > 0);
}
</script>
Above is the function that is called by the CustomValidator, i.e. the property of the Validator’s ClientValidationFunction in the code below. I use the jquery Class selector because it is much easier than trying to figure out the rendered ID of the generated web part html.
The Code selects all CheckBoxes which are checked in the Panel and checks the length of the collection, if it’s 0 nothing was checked, so args.IsValid is false etc etc.
<asp:Panel ID="pnlBoxes" runat="server">
<asp:CheckBoxList ID="cbList1" runat="server">
<asp:ListItem>Zero</asp:ListItem>
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
</asp:CheckBoxList>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ValidateChecked"
ErrorMessage="Just Check something!!" Display="Dynamic" ></asp:CustomValidator>
</asp:Panel>
I used this code in a SharePoint environment in a web part which was rendered entirely through code, thus the use of an asp:Panel instead of a Div.
Monday, April 13, 2009
Creating K2 Environment Fields with Environment Library API
I know that you can use a deployment package to move environment settings to different servers, but I wanted to see if I can create them programmatically. The process of creating Environment Fields can be a time consuming and tedious task, especially if you have a large number of fields. Typically in a real-world project, a list of Fields are already defined in a functional document somewhere, so to have a utility which can create fields from a list in a text file for example could be a big time saver. At the time of this writing, documentation on how to do this kind of thing was rather scarce, hence this post ;-)
The trick is to get a new instance of an Environment Field since is doesn’t have a new() constructor, you have to get a new instance by using the CreateFieldInstance() method of the EnvironmentFieldType class.
Steps:
- Create a new EnvironmentSettingsManager Instance and Connect to the K2 Server using the ConnectToServer() method of the EnvironmentSettingsManager instance.
- Create a new EnvironmentTemplateCollection Instance and a new EnvironmentInstanceCollection Instance.
- Select the Environment Template to use (e.g. Default Template) and select the Environment to use (e.g. Development)
- Get a handle on the EnvironmentFieldType you want to use by calling the EnvironmentSettingsManager.EnvironmentFieldTypes.GetItemByFriendlyName("Miscellaneous Field")
- Get a new EnvironmentField instance by calling CreateFieldInstance() method of the EnvironmentFieldType instance.
- Set the properties of the EnvironmentField instance
- Add the Field to the EnvironmentFieldCollection of the Environment Instance with the Add(newField) method of the EnvironmentFieldCollection
- Call the SaveUpdate() method of the EnvironmentField
Code:
EnvironmentInstance ei = new EnvironmentInstance();
ei = eic.GetItemByName("Development");
esm.ChangeEnvironment(ei.EnvironmentId);
EnvironmentFieldType eft = esm.EnvironmentFieldTypes.GetItemByFriendlyName("Miscellaneous Field");
EnvironmentField ef = (EnvironmentField)eft.CreateFieldInstance();
ef.FieldName = "DeonTestField";
ef.FieldDescription = "Deon Test Field";
ef.DisplayName = "DeonTestField";
ef.Value = "Some Value in Here";
efc = new EnvironmentFieldCollection(ei);
efc = ei.EnvironmentFields;
efc.Add(ef);
ef.SaveUpdate();
Friday, October 03, 2008
K2 BlackPearl 807
The 807 version of BlackPearl was released on the 24th of September and so far I am pretty impressed. The Workspace
Management console features a new section called User Managers where you can configure your additional AD Domains.
The long awaited Out-Of-Office features are also in 807, and it's great!! Some highlights:
- A user can configure multiple users as recipients of his worklist items when he's out of office
- He can create Exception Rules, to send Worklist items for specific activities to different users while out-of-office
- An administrator can create and edit out-of-office rules for users
- Existing worklist items are immediately delegated to the designated users when out-of-office is tuned on.
Note: If you are using the Workflow Client API to action worklist items, you have to take additional steps to handle out-of-office functionality, specifically you have to check for the presence of the SharedUser Query string an addition to the Serial Number (SN) Query String, following is some sample code:
private void openMyTask()
{
string sn = Request.QueryString["SN"];
if (sn != null && sn != "")
{
Connection k2Conn = new Connection();
WorklistItem wli;
try
{
k2Conn.Open(ConfigurationManager.AppSettings["k2Connection"]);
wli = getWLI(k2Conn, sn, Request.QueryString["SharedUser"], Request.QueryString["ManagedUser"]);
//get Data Fields
//get Actions
//etc.
}
catch (Exception ex)
{
//Handle Exception
}
finally
{
k2Conn.Close();
}
}
else
{
//No Serial Number - show Error
}
}
private WorklistItem getWLI(Connection conn, string serialNumber, string sharedUser,string managedUser)
{
WorklistItem worklistItem = null;
// normal user
if ((sharedUser == null) && (managedUser == null))
{
worklistItem = conn.OpenWorklistItem(serialNumber, "ASP");
}
// Out of Office user
if ((sharedUser != null) && (managedUser == null))
{
worklistItem = conn.OpenSharedWorklistItem(sharedUser, managedUser, serialNumber);
}
// normal Manager
if ((sharedUser == null) && (managedUser != null))
{
worklistItem = conn.OpenManagedWorklistItem(managedUser, serialNumber);
}
// Out of Office Manager
if ((sharedUser != null) && (managedUser != null))
{
worklistItem = conn.OpenSharedWorklistItem(sharedUser, managedUser, serialNumber);
}
return worklistItem;
}
}
Technorati Tags: K2 Blackpearl 807
Friday, July 11, 2008
New Dev Environment
It is finally up and running!
My Dell E1505 with 2 GB RAM was just not cutting it anymore, it worked fine for K2.net 2003 Dev but the resource requirements for K2 [blackpearl] has grown substantially. Even if I upgrade to a super notebook with 4 GB RAM, I still would be limited in what I want out of a proper Dev environment. I wanted to have an environment which closely matches real-world K2 production environments, and trying to build that with decent performance on a Notebook with 4 GB RAM is close to impossible.
So, I decided to move my DEV environment from my notebook onto a virtualization server. Now I have 5 virtual servers and a virtual workstation as my new DEV environment. It is a true multi-domain distributed K2 environment. The beauty is that I was able to build a fairly powerful Virtual Host Server for about the same price as a high-end 4 GB Notebook, i.e. for about $2000. Here is what 2000 bucks got me:
Rack Server from serversdirect.com (http://www.serversdirect.com)
· Motherboard: Supermicro X7DVL-I Server Board
· CPU #1: Intel Quad-Core Xeon E5405 Processor @ 2.00GHz
· CPU #2: Intel Quad-Core Xeon E5405 Processor @ 2.00GHz
· Memory: 10 GB , ECC Fully Buffered
· Disk I/O: 6x SATA2 3.0Gbps Ports via
· H/Disk #1: Seagate SATAII 160GB
· H/Disk #2: Maxtor SATAII 1TB
· Network: Integrated Intel Dual-Port Gigabit Ethernet Controller
And, this is what it looks like:
Thursday, July 10, 2008
Multi-Domain blues update 2
Turns out there is a small problem with K2 caching of AD users in a multi-domain environment. A fix should be included in the next release of blackpearl. The work-around in the interim is to turn off caching by:
Changing the 'ADCache' value in the RoleInit column of the security label to 0 (the default is 10).
For example:
"<roleprovider><init>ADCache=0;LDAPPath=LDAP://DC=K2DEMO,DC=LOCAL;..."
This will force K2 to always query AD rather than using the cache.
Thursday, July 03, 2008
K2 Kerberos Troubleshooting
I recently had a hard time troubleshooting a Kerberos issue at a client. The Kerberos goodies (SPN's, Delegation etc) were created by the SysAdmin team based on instructions from me but unfortunately I was not present when they did so I had to verify the Kerberos setup after everything was created. The symptoms was the usual, APP Pool service account auth to K2 server using NTLM and naturally the user credentials aren't delegated, resulting in Anonymous connection to K2 server. Everything checked out: SPN's on K2 Server Service Account, SPN's on APP Pool Account, constrained delegation from APP Pool to K2 Server configured etc. After much head scratching I discovered a DUPLICATE set of SPN's on the K2 Services which caused Kerberos to break. A Service can only run as one account, so to create another set of SPN's for the SAME Services on another account is a no-no. The following would be a problem (not showing FQN SPN's):
ServiceAccount1 SPN's:
K2Server/SERVERA:5252
K2HostServer/SERVERA:5555
ServiceAccount2 SPN's:
K2Server/SERVERA:5252
K2HostServer/SERVERA:5555
Delete the SPN's for ServiceAccount2 and you're good to go.
