Category: Work > ECM

K2 SmartObject Event – InfoPath XmlFields bug

So, this is the first time that I’m blogging about a K2 problem I’ve had for a while… At work we have a nice mail and registration process and with the new K2 BlackPearl we’d like to be able to design the process with “nice” InfoPath forms (since they are easy to create).

K2 BlackPearl has some great integration with InfoPath, SharePoint and SmartObjects. The Mail and Registration process is quite simple. It gets triggered when a document is placed inside an Document Library. The process then creates a SmartObject to store metadata of the document (like a URL and name of the document). The next step is to show the user a infopath form to add extra data, including a link to the document that has been uploaded to the document library.

Now there’s a small problem, the infopath form needs a reference (the SmartObject ID) to the SmartObject to load that data, unfortunately you aren’t able to put return values from a smartobject directly into the XmlField of the InfoPath form without using code. The XmlField is the XML representation used by the K2 process for the infopath form, so changing the XmlField values changes the content of the infopath form associated to the process.

A SmartObject Event would be used to create the SmartObject with metadata and then store the returned SmartObject ID into the XmlFields. The SmartObject event probably has a small bug (already reported) which makes it unable to use the InfoPath XmlFields.

To fix this, you can store the return value of the SmartObject in a process DataField and in a server/code event put that into the Xmlfield. The code looks something like this:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(K2.ProcessInstance.XmlFields["ECMInput"].Value);
xmlDoc.PreserveWhitespace = true;

XmlNode xmlnode = xmlDoc.GetElementsByTagName(“my:ECMMetaDataID”)[0];
xmlnode.InnerText = Convert.ToString(((long)K2.ProcessInstance.DataFields["MetaDataID"].Value));

K2.ProcessInstance.XmlFields["ECMInput"].Value = xmlDoc.OuterXml;

The first few lines just load the XmlField named ECMInput into an XmlDocument. Then we get the node that we want to change (GetElementByTagname(“my:ECMMetaDataID”)[0]) and we start to alter the data. The DataFields[].Value returns a object, and we defined it as long, so there’s a cast, and then a Convert.ToString() to get it to go into the InnerText property of the xmlNode. After that we just load the XmlDoc back into the XmlField. Btw, the PreserveWhitespace is required for InfoPath to work properly with digital signatures!

So, that’s basicly it, a small piece of code to get it all together!

Day 1 of the Berlin SharePoint 2007 Conference

Yesterday was the first day in berlin. The flight (the day before yesterday) was short and dark. The landing was rather weird because it was cloudy and the pilot sad there was a freezing drizzle. So people looked at each other like ‘how are we going to brake?’. The wheels touched the ground and the pilot slammed the brakes, everything went as normal :)

The airport was small but nice, then in a taxi to the hotel, checked in and had a drink with my collegues.

Sessions – really day 1
So, yesterday was the real day of the conference. I’m not going to describe every session, but some where good and some wheren’t. I gues that was to be expected :)

The K2 blackperl session was good, the presenter wasn’t that good and he went very quick, also he’s demo crashed or had bugs. In general i think K2 Black perl will add a lot of stuff to the ECM project that i’m working on. I can’t wait to get the beta and start working on it.

Another presentation that i liked was the one from Patrick Tiggesem from U2U. The info was good, low level but also a little in depth. I went to two sessions from him and i sure hope he stops mentioning that SmartPart, that shameless plugg drops by every time you hear a session from the U2U guys. Don’t get me wrong, it’s a nice product, but come on, stop promoting it like it’s a requirement!

Evening program
In the evening we had a diner, what impressed me was the enormous room where with all the tables set up in under 2 hours. It reminds me of the AXA Cathering that Gasterij De Vendel had when i still worked there part time. I do see a lot of people walking around doing lot’s of stuff, compliments to Hotel Estrel.

WordPress Themes