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.

Tuesday, 14 August 2007

Sharepoint Administration Tips 1 - Pitfalls in Moving Sharepoint DB

At some point we have to move database for sharepoint configuration either because the DB file / log is on system drive or the fast expanding of your sharpeoint DB log. If DB is full, you can still view the website hosted by sharepoint, but a lot of functions will stop working.

First thing first, do a full backup or differential backup if you have a full backup before. After that, to move the database, please read the relevant links in here;To move the database to another server, read here.

Note below:
After you have done the moving, you might run into problems like search settings changed , timer services stopped working correctly. For Search settings, we need to make sure the indexer is assigned to the SSP since moving the sharepoint will remove this. If you have enabled incoming email services for your sharepoint lists. It will stop working because the relationship between web app and sharepoint timer called Windows Sharepoint Incoming Email Timer is broken. To restore this, Go to Operation->Incoming Email Config->Select No on "
Enable sites on this server to receive e-mail? "->click ok and then come back to click "yes". After this, make sure to disable and re-enable the Application Server Administration Service Timer Job " and " Application Server Timer Job "this should fix the problem on incoming email.

Thursday, 19 July 2007

Sharepoint Development Tips 5- Customize MOSS TimerJob

No intention to steal the posts from other people here since Andrew Connell has posted a very nice and detailed article on his blog introducing how to create custom timer job on MOSS. He is kind enough to post his sample project as well.


In his article , he packaged the dll using solution file(*.wsp), here I just introduce how to deploy it using a simple feature if you don't want to add the whole deal with other dlls.

The only difference, as you might already find out, is the xml files. So for the feature.xml, it will be as following

and please note that the "Hidden" value is set to "True", for the UI user can use to turn on/off in sharepoint is using the application pool account to access the content DB, which will be permission denied if you don't grant your account to the DB. So it will fail when you activate the feature.
And the manifest file elements.xml is as following
Note that you have to specify a listtemplateid here, even though you don't want to bind it to any list or doc library.

At last, you should be cautious when changing the code and update the assembly. Sometimes even if you updated the GAC and did a iisreset, it still won't pick up the new one. You have to restart Windows! See my other post regarding this same problem with SPD workflow!

Thursday, 5 July 2007

Sharepoint Development Tips 4- SPD workflow madness

As I introduced SPD workflow in my previous post,if all you need is simply customized activity and it's supposed to be stand-alone, i.e. doesn't need to be reused to another list in sharepoint, and you certainly don't want the hassle with init,complete forms with InfoPath, customized activity/condition with SPD's workflow designer is almost perfect choice. But when any offer looks too good to be true, it probably just is. Like the line in Supernatural, "This world just ain't coming without perks...", well, in the bad way in our case of course !-_-...

The catch is when you want to update your code using SPD, you will find the change you made will not be used by sharepoint. And as you come this far with it already, you know there's NO debugging support with SPD workflow. You really want to make sure it "somehow" just works anyway before you deploy it to the server. So how on earth we can make our updated dll work with the SPD workflow on the server? Well, you will have to live with the fact that you can't debug given the fact your dll will not contain huge amount of code. But to update the dll on the server, do the following.

1. Remove the workflow from your list in sharepoint
2. Shut down your SPD
3. Go to your website cache, on my XP pro the path for this is : "C:\Documents and Settings\%user%\Local Settings\Application Data\Microsoft\WebsiteCache", in vista , it's under different path:%System Drive%\Users\%user%AppData\Local\Microsoft\WebSiteCache(You will find it's a mistake to use Vista for professional development for now anyway). Delete everything you see there.
4. Copy the updated dll to the GAC on your server
5. IISRESET on your server
6. reopen SPD
7. Redeploy your workflow.


In this way, you will update your SPD workflow with latest dll. But I have run into the occasions that even above method will not update your dll. I ended up restarting the sharepoint server to get it updated(too much for a real-world software solution , is it?). Hopefully this will help you.

Update:
now every time I have to restart the sharepoint server to make changes. :(