Wednesday 26 September 2007

Infopath Development Tips 1 - Infopath repeating table manipulation

Infopath forms are the essential part of sharepoint workflow development. Repeating table is also very tempting because it can solve many UI problems when presenting group of data. So the problem is , how do we populate repeating table from the data we have. It's easy. AppendChild method of DOM using managed code and Infopath's powerful conditional formatting.
1. First thing first, let's specify the conditional formatting for repeating table. right click the table, then properties->conditional formatting-> add. Then you can specify when the value of element of table, say , text box is blank, tick "hide this control". This will make sure your table doesn't show extra blank row when inserting the rows. We will see why we might need to hide this row later on.

2. Secondly, we need to use a little code behind to populate the table we have in the IP form. Say the name of the table we have is called docList and the collection of data we have is docArray. so the code will be



//repeating table

relDocListTable = mainRoot.SelectSingleNode("/my:myFields/my:docList", this.NamespaceManager);


//repeating table row
relDocListRow = mainRoot.SelectSingleNode("/my:myFields/my:docList/my:docItem", this.NamespaceManager);

for (int index = 0; index < newrow =" relDocListRow.Clone();" innerxml =" docNameArr[index];">

Wednesday 12 September 2007

Sharepoint Development Tips 6 - Developing Visual Studio Workflow for MOSS

pitfall 1:

there's a good article (well, for starters ) on msdn you guys can read to start your very first workflow using Visual Studio. But after firing up VS 2005 and ready to go with the instructions of this article, you found there's no onworkflowactivated1 as your necessary starter of the dish... so basically that's how the init data will kick in from MOSS and your workflow won't work without it. Even if you add those 3 missing references already and are able to see the chart , it will be the same.

Solution: Don't trying to be clever, install ECM kit on your development server with sharepoint on, copy around the dll files needed by your project is not good enough this time.

pitfall 2:

The snippet is essential to have when completing your workflow.xml and feature.xml in order to install your workflow and all related Infopath forms. Rather than google on the Internet, as we know, MS provides this snippet coming with the ECM kit. But when you press ^K+X, the WSS snippet described in MSDN is not there.

Solution:
Serge Luka's blog did save us a lot of time to tell us where this snippet is. Simply press ^K+B to navigate to the path of "C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets\Windows SharePoint Services Workflow" and add the snippet code into your code snippet manager. There should be another one for MOSS but the workflow.xml and feature.xml should be the same.

pitfall 3

SendEmail activity always seems tempting when developing workflows using Visual Studio because email can be a very important process. While a lot of people complaining the activity does not do what it is supposed to even though there's no error in event viewer of Windows or ULS log of MOSS. Can it be security issues or central admin's outgoing email settings, etc... confusing

Solution:
Wake up, the MailMessage utility in System.net still works as well as in .net 2. If you know the smtp server's address , this can be perfect to use in this scenario. Anyway, even if SendEmail Activity works, you still have to specify the to, from, and body so on to make it send emails you want. MailMessage object that can be sent by SmtpClient is easier to handle. Just drag a code activity instead and put your SmtpClient+MailMessage inside the handler of that code activity. It's guaranteed working if you get your smtp outbound server's address.