Search This Blog

Friday, January 25, 2008

Avoiding memory leak in custom SharePoint code

In SharePoint applications with large customizations using custom code if objects using umanaged resources are not disposed, it would lead to memory leaks. The w3p process memory would drain quickly as more requests keep coming over a period of time.
You could check this quickly by looking at Virtual Memory in task manager. Other way would be to look at Private Bytes and .Net Memory performance counters.
Check your code for few obvious ones:

a) using (SPWeb web = new SPWeb(.....) )
b) using (SPWeb web = site.openWeb() )
c) Similary disposing the SpSite objects

Some other one are:

a) using (SPWeb web = site.openWeb() )
{
SPWeb parentWeb = web.parentWeb;

}
and even the
rootWeb property



Hope this helps...

Updating a workflow from custom code / Trigger ontaskchanged from code

At times there is a need to update workflow task items in Workflow Task library in SharePoint site thru custom code. The key line of code to make that update and hence force a ontaskchanged event fire is :

workflowItem["Completed"] = true;
....

Sunday, January 13, 2008

Infopath Web Form - Cascading dropdown in a Grid

In Infopath web forms, drop down cascading is not an out of box feature. Lot of posts have been made around for making that work. However to have a cascading dropdowns within a Grid on the web form, needs a little more work. Am putting the design on how this will work.
Scenerio: Each row of the grid has two drop downs i.e. Region and State. On selecting region the state drop down shows states correponding to the region selected in the same row. Here is a design for accomplishing this.

Given the Main data source with a following schema:

Main
ABC(Repeating Group bound to the Grid on the form)
RegionValue ( drop down value selected by Region drop down is stored in this)
StateDropDown (create a repeating Group here below ABC)
StateNameDropDownValue
StateNameDropDownDisplay


Now you need to have custom code to fill in the values for StateDropDown repeating group elements StateNameDropDownValue and StateNameDropDownDisplay thru "code"for in the given row.
Change the state Drop down to bind to the repeating group StateDropDown elements i.e. value to StateNameDropDownValue and Display Name to StateNameDropDownDisplay.

This fixes that issue however has one small disadvantage i.e.

The listitems for each state drop down will be stored along with InfoPath XML file so little more space is occupied in the persisted data.

Mo

Saturday, January 12, 2008

Intro

Hi There,
Please allow my to instroduce myself. I am Mohan Taneja from California. Work as MOSS / .Net Architect. I thought of starting this blog to share my views on different areas in Technology.
I hope that these may be of some use to you, at some point of time.

Mo