Tuesday, June 30, 2009

How to MASS remove item in list

The typical answer is to do a looping to remove all items one by one. This required multiple call to the server. Check out the following approach


private static StringBuilder BatchDeleteCommand(SPList spList)
{
StringBuilder sbDelete = new StringBuilder();
sbDelete.Append("< ? xml version=\ "1.0\" encoding=\"UTF-8\"?>");
string command = "" + spList.ID +
"< / SetList>{0}< / SetVar>Delete< / SetVar>< / Method >";

foreach (SPListItem item in spList.Items)
{
sbDelete.Append(string.Format(command, item.ID.ToString()));
}
sbDelete.Append("
");
return sbDelete;
}

how to build web part

This article shows how to build a webpart from scratch using GAC approach. This msdn article describes the steps to build a webpart with CreateChildControls()

programming in infopath + print view

Interesting article to describe how to perform coding in infopath to send email and close the form.

And it might be useful to talk about the print view. Very often after we submit the form, we need to print it. print view become handy when you have different form view for input and printout. Refer to this article for more details

More example

how to host infopath in asp.net web form

I come across on some articles to describe how to host infopath in asp.net web form, which is using xmlFormView control.

And this article describe how to generate pdf from it using custom asp.net web form but it will lose the capability to dynamically update the column to sharepoint list.

Monday, June 29, 2009

How to deal with infopath object

Good article to share. Highlight

string xpath = "/my:myFields/my:field1";
XPathNavigator field1 = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
string oldValue = field1.Value; // Read
field1.SetValue(“New Value”); // Write

Auto Generating file name for infopath post

For those who has infopath experience will find it very ignoring that you need to provide the file name for the submitted infopath form.

To achieve this we can use timestamp as the fileName, but this will create another entry when you edit the form.

Refer to this on how to do it.

Wednesday, June 24, 2009

Infopath VS web form

With the popularity of infopath, we come to a cross-junction to ask why infopath and not web form. This article highlights the key difference between these.

One key advantage of infopath is the turnaround time, with it, System Integrator can build the infopath form from scratch and subsequently user can add new column / remove existing column from the form without any technical knowledge required.

The drawback is that Infopath license is required.

Wednesday, June 3, 2009

Content Deployment API

If you tried on content publishing before then you may ask if it is possible to trigger the content publishing job using CODE.

The answer is YES.

string centralAdminUrl = "http://office2007:15688";
SPSite adminSite = new SPSite(centralAdminUrl);
SPWeb adminWeb = adminSite.OpenWeb();
SPList pathList = adminWeb.Lists["Content Deployment Paths"]; ContentDeploymentPathCollection paths = new ContentDeploymentPathCollection(pathList.Items);

You can access various properties or method thru paths collection. It is as good as the list of path that you see in the content deployment page in central admin.

Refer here to find out more

Coding Best Practise

I come across a very good article on best practice and common issues.

Monday, June 1, 2009

Sharepoint Sales video

This video highlights the overall features (the 6 pillars of MOSS) in MOSS 2007.