Showing posts with label K2. Show all posts
Showing posts with label K2. Show all posts

Monday, November 23, 2009

Add InfoPath fields to Notification Email

In one of my K2 project which is an InfoPath Integrated Workflow, the users would like to see some information in InfoPath form, such as Company Name, Region, Office and so on in the notification email, so they can easily figure out what this email is about.

Well, this is a very good suggestion. Unfortunately in Notification Email Design Wizard in K2 workspace, there’s no way to get XML fields in the InfoPath form. After some investigations, I found Data Fields show in the Notification Email Design wizard. So we can create Data Fields and assign values for these data fields from xml fields. It is pretty simply to do it. The following sample creates two data fields Office and AdminRegion. In the workflow, add a Default Server Event (code), add the following code:

// The xml string in K2
string xml = K2.ProcessInstance.XmlFields["XML root field name"].Value;
// Load xml string to a xml object
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);

XmlNamespaceManager nsgr = new XmlNamespaceManager(doc.NameTable);
nsgr.AddNamespace("my",doc.DocumentElement.GetNamespaceOfPrefix("my"));

//Get Office value
string office = doc.SelectSingleNode("//my:Office",nsgr).InnerText;

//Get AdminRegion value
string adminRegion = doc.SelectSingleNode("//my:AdminRegion", nsgr).InnerText;

K2.ProcessInstance.DataFields["Office"].Value = office;
K2.ProcessInstance.DataFields["AdminRegion"].Value = adminRegion;



Now we can use Office and AdminRegion which are populated from the form in Notification email.

Monday, June 15, 2009

An Issue in Updating SharePoint Form Library Column from K2

This is the same K2 InfoPath Integrated workflow which mentioned in my last post. After the form is uploaded to the SharePoint form library, I’m trying to use K2 SharePoint Document Events to update SharePoint library columns(the values are from some fields in the form). For most test cases, it works fine. But I get the following error if there’re special character such as ‘&’, ‘<’ and ‘>’ in the field which is used to update the column.

An error occurred while parsing EntityName. Line 1, position 1945.

It seems this is a known issue and K2 support told me they will fix this issue in the next SP. Well, I can’t wait for them as this workflow is running in my production. Luckily I figured out a simple solution. When publishing the form to SharePoint form library, in the publish wizard at “You can make forma data listed below available as column names on a SharePoint site” step, I chose the fields which were used as columns. And then in K2, I removed K2 SharePoint Document Events which I used to update the library columns. In another words, I used SharePoint to update the columns from the form fields instead of using K2 to update SharePoint columns. It works perfectly.

Access to the path ’Employee_Req.xsn’ is denied

I have a HR workflow which was developed on K2 platform. It is an InfoPath integrated workflow, and Employee_Req.xsn is my form name. When I built my project, I got this error: Access to the path ‘Employee_Req.xsn’ is denied. I noted the form was checked out from VSS so there shouldn’t have access problem.

This didn’t happen before I upgraded K2 BlackPearl from SP1 to 0807 with build number 4.8210.2.0. After lots of investigations, I found K2 automatically created a deployment package under obj\Debug when building, and the form was copied to obj\Debug\Deployment\Bin. I think K2 copied the form before I checked it out, so the form in that folder was still Read-Only. Now the fix is pretty simply, just uncheck Read-Only property box, or delete the whole Deployment folder under obj\Debug.

Months ago, I upgraded K2 from 0807 4.8210.2.0 to 0807.8210.2.370, and this issue doesn’t happen again.

Monday, June 1, 2009

Get Error When Browsing K2 Workspace

When browsing K2 workspace, I got the following error in the page:

Error:Initialization failed: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: indexAn error has occurred.Please contact your administrator.
Error:Initialization failed before PreInit: Thread was being aborted.
Possible causes- using anonymous logon in IIS while Windows security is specified in Workspace configuration- current logged on user can not be verified against the Active Directory Membership provider- please review log files for more information

Many people met the same problem. I don’t know why K2 doesn’t try to fix it. The solution is pretty simple. Go to \Program Files\K2 blackpearl\WorkSpace\Site, open the web.config file, find connectionString="LDAP://fulldomainname”, add “:389” at the end. So it looks like:

connectionString="LDAP://fulldomainname:389”

Browse K2 workspace again and it works!