During the same recent
BizTalk POC I mentioned previously, I had the occasion to try and store rich HTML in a BizTalk schema for use in
a Microsoft InfoPath RichTextBox field. I had to work a little magic, and thought I’d share that here.
The first thing I had to do was build a schema containing a field that would work with InfoPath. The RichTextBox wouldn’t work
with just any old string. What I did was build a node (Docs) containing an “Any” element that
had Lax content processing, and most importantly, a namespace of http://www.w3.org/1999/xhtml.
Once I saved that schema and created a new InfoPath form which utilized it, you’ll see that the data type of Docs is now
equal to XHTML.
Now I could use that field as a RichTextBox. Why does that matter? Well, I wanted to store valid hyperlinks in the field that the
form viewer could then click on. These links are to the binary docs processed in the
earlier blog post. As you can see here, the RichTextBox
allows you to store all kinds of HTML formatted-data.
So now that I had my form and schema, I had to populate that XML element with valid HTML. So, in my orchestration, after I receive
each binary document (e.g. Word, Excel, PDF) from the inbound web service, I store the binary document in SharePoint, and use a helper
component to create a hyperlink pointing to the document’s new location. I used the code below to create a StringBuilder holding
each document hyperlink …
public void AddDocToList(string docName)
StringBuilder addressString = new StringBuilder();
//WSSSite is a global variable pointing to the SharePoint doc library
addressString.Append(@”‘” + WSSSite + “/” + docName + ” ‘>”);
I also have a helper method called GetDocList which, when all binary docs have been received, takes the StringBuilder and
turns it into an XmlElement. That code is also simple and looks like this …
public XmlElement GetDocList()
XmlDocument tempDoc = new XmlDocument();
tempDoc.LoadXml(“<span>” + sb.ToString() + “</span>”);
In my orchestration, I call this GetDocList method and set its return value to the XPath node in my XML document. Now when
the user opens up the InfoPath form to review the current activities, they have a nice, hyperlink-enabled list of all supporting
documentation. Of course you could also use this for an ASP.NET viewer, not just Microsoft InfoPath.
Technorati Tags: BizTalk