Thursday, May 6, 2010

EventHandlers for Survey List.

Few facts about Survey List Event Handler:
1. If the survey has Page Separator, then when click on next button on first page of survey then ItemAdded event will trigger.
2. After that for every Next Button click on survey will call ItemUpdated. Even at the end a Finish button will also call ItemUpdated event.
3. To achieve the goal with EventHandler on Survey list, you can use following properties,
* SPListItem.HasPublishedVersion
* SPListItem.Level
* SPListItem.MissingRequiredFields

indrajitk@gmail.com
http://blogindrajeet.blogspot.com

Tuesday, May 4, 2010

Attach event handler in SharePoint

SPSecurity.RunWithElevatedPrivileges(delegate()
{

SPSite sps = new SPSite("http://test:1659/");
SPWeb impersonateweb = sps.OpenWeb();
impersonateweb.AllowUnsafeUpdates = true;
SPList _spListAanwezige = impersonateweb.Lists["Survey"];
_spListAanwezige.EventReceivers.Add(SPEventReceiverType.ItemAdded,
"ReplicateData, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1f0faf7eec29149f", "ReplicateData.SurveyEventHandler");
impersonateweb.AllowUnsafeUpdates = false;

});

Can not attach workflow to Survey list.

The status of a workflow appears as "Failed to Start" when you try to start a workflow from a survey response in Windows SharePoint Services 3.0

http://support.microsoft.com/kb/926370

Tuesday, April 27, 2010

Edit Forms like - NewForm.aspx,EditForm.aspx

This the only magical word you need to add at the end of your url.
"&toolpaneview=2"
It will allow you add webpart with all the Edit Webpart functionality.

The sample url will look like this:
http://SiteName/sites/TestSite/Lists/TestList/NewForm.aspx?RootFolder=%2Fsites%2FTestSite%2FLists%2FTestList&toolpaneview=2

SharePoint 2010 : How to Forms Based Authentication (FBA)

Very good walk-through.

Friday, April 23, 2010

Sharepoint : Create Custom View for Survey

Generally Surveys do not allow you create a custom view for the survey. But i want to create it.

Lets do it. Its very simple.

To create custom view for the survey.

1. Go to the list Settings, which allows you to create custom view.
2. Change list GUID from the ViewType.aspx url
3. It will allow you to create Custom View.

Regards,
indrajitk@gmail.com

Thanks to Nishant

Wednesday, March 31, 2010

SAP SharePoint Integration Important Links

/////////Microsoft BizTalk Adapter Pack 2.0/////////


Microsoft BizTalk Adapter Pack 2.0
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=47ab6f21-0d8b-4c90-a8b9-e8647281b164

WCF LOB Adapter SDK SP2
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=47ab6f21-0d8b-4c90-a8b9-e8647281b164

Prerequisite Software Requirement
You must install this software prior to installing the WCF LOB Adapter SDK.
a. Microsoft .NET Framework 3.5 SP1
b. Microsoft Visual Studio 2005 or Microsoft Visual Studio 2008
Note: You require this only if you want to either build custom adapters or develop solutions that use the adapters built using the WCF LOB Adapter SDK.
c. Microsoft BizTalk Server 2006 R2 or Microsoft BizTalk Server 2009
Note: You require this only if you want to use the adapters with BizTalk.



/////////Microsoft BizTalk Adapter Pack 1.0/////////
Prerequisite Software Requirement
You must install this software prior to installing the WCF LOB Adapter SDK.
a. Microsoft .NET Framework 3.0+
b. Microsoft Visual Studio 2005




WCF LOB Adapter SDK SP1
http://www.microsoft.com/downloads/details.aspx?FamilyId=0F8007D7-F0C9-4169-8B9C-BA55F8F4C153&displaylang=en

Microsoft BizTalk Adapter Pack 1.0
http://www.microsoft.com/downloads/details.aspx?FamilyID=F3EA0659-B0ED-4D5A-891E-53268128A5F0&displaylang=en&displaylang=en


Required SAP DLLS
http://blogs.msdn.com/adapters/archive/2007/10/07/obtaining-the-rfc-sdk-unicode-libraries-from-sap-service-marketplace.aspx

Thanks,
Indrajeet Kumpavat
Mail me : indrajitk@gmail.com

Create a RFC function module in SAP

http://www.saptechnical.com/Tutorials/ABAP/FunctionModule/page1.htm

Monday, January 11, 2010

Access Site Defination Xml via URL

Just type the following URL in the browser. It will show the detailed Site Defination Project schema from ONET.xml.

<SiteUrl>/_vti_bin/owssvr.dll?Cmd=getprojschema

Wednesday, December 9, 2009

Set Item level permission in Sharepoint Document Library

In Documnet library, we can not set item level permission by using Sharepoint Document Library Settings (unlike sharepoint List Settings). There is a very simple code snippet which does the same for us.

Code snippet

using (SPSite spSiteObje = new SPSite("http://SiteColName/Subsite"))
{
using (SPWeb spObjWeb = site.OpenWeb())
{
SPList spObjDocLib = web.Lists["MyDocLib"];
spObjDocLib.ReadSecurity = 2;
spObjDocLib.WriteSecurity = 2;
spObjDocLib.Update();
}
}

Use ListViewWebPart to display listdata from different than current sharepoint site.

using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace TestDashboard
{
[Guid("b732479d-6bcd-4dd9-97de-85f11bsdc5cb")]
public class TestDashboard : System.Web.UI.WebControls.WebParts.WebPart
{
public TestDashboard()
{
}

protected override void CreateChildControls()
{
base.CreateChildControls();

ListViewWebPart wp = new ListViewWebPart();
SPSite objSpSite = null;
using (objSpSite = new SPSite("http://SiteColName/SiteName/"))
{
objSpSite = new SPSite("http://SiteColName/SiteName/", objSpSite.SystemAccount.UserToken);
using (SPWeb spweb = objSpSite.OpenWeb())
{
SPList splist = spweb.Lists["ListName"];

wp.ListName = splist.ID.ToString("B").ToUpper();
wp.ViewGuid = splist.Views["All Items"].ID.ToString("B").ToUpper();
wp.ViewType = ViewType.Html;
wp.WebId = spweb.ID;
wp.SuppressWebPartChrome = true;
wp.GetDesignTimeHtml();
this.Controls.Add(wp);
}
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
EnsureChildControls();

}
}
}

Wednesday, December 2, 2009

Customize EditForm.aspx, AllItems.aspx or any forms.

1. Goto Sharepoint designer.
2. Open desired site and then list in folder view.
3. Copy EditForm.aspx and paste it
4. Rename the newly copied EditForm.aspx ( MyEditForm.aspx)
5. In new MyEditForm.aspx go to code view.
6. Search for ListFormWebPart. (WebPartPages:ListFormWebPart)
7. Go to the properties of ListFormWebPart (Webpart properties)
8. Check the hidden check box under layouts section. (Layouts/Hidden)
9. THen,
10. Go to Insert menu.
11. Select Sharepoint Controls.
12. Add Custom List Form.
13. It will expose the whole webpart in a form of text boxes,lables and all HTML controls.


You can play with them by hide/show or whatever you want to achieve. Nice enough???

Note: By doing so, you will also able to add column values for Folder also. I mean, generally you can not add properties of Folder, unlike you can do for a list item or a Document. But this process will enable you to add properties of folder.

Monday, November 30, 2009

Accept mail and create an item in Document Library

This feature allow us to add a new item in a document library by sending an email to the specified email address.

Go to Document Library Settting -> Incoming mail setting(Under communication tab)

Really good one!!

Help Link :
http://blogs.msdn.com/selvagan/archive/2008/01/26/incoming-email-configuration-moss.aspx






Application page with UnsecuredLayoutsPageBase

Sharepoint site with secure socket layer (Https) requires to be inherited with "UnsecuredLayoutsPageBase"

See the code sample given below:


public class Class1 :UnsecuredLayoutsPageBase
{
protected Label lblSiteTitle;
protected Label lblSiteID;
protected DropDownList DropDownList1;
protected override void OnLoad(EventArgs e)
{
SPWeb site = this.Web;
lblSiteTitle.Text = site.Title;
lblSiteID.Text = site.ID.ToString().ToUpper();
}
protected void Button_Click(object sender, EventArgs e)
{
Response.Write(DropDownList1.SelectedValue);
}
}

Get List Data using SPView

Check code snippet:

SPWeb spWebTest = siteCollection.RootWeb.Webs["Test"];
SPList splTestDetails = spWebTest.Lists["TestTeam"];

//Get the Test person names from Test site
SPView spvTestPerson = splTestDetails.Views["TestPerson"];

DataTable dtTestPerson = splTestDetails.GetItems(spvTestPerson).GetDataTable();

SpDisposeChecker tool - check memory leak in sharepoint



http://code.msdn.microsoft.com/SPDisposeCheck


Another good one for .Net : http://msdn.microsoft.com/en-us/library/ee658248.aspx

Thursday, November 19, 2009

Few very useful paths for sharepoint professionals

  1. 12 hive
  2. Assembly
  3. WSS for Web.config changes
  4. <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,PublicKeyToken=71E9BCE111E9429C" % >

Friday, November 13, 2009

Flash in Sharepoint

Use content editor webpart.
Use following code for source of CEWP

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="worldtime" align="middle">

<param name="allowScriptAccess" value="servernamesharepoint" />

<param name="movie" value="http://servernamesharepoint/Test/TestDoclib/flashslide.swf" />

<param name="quality" value="high" />

<param name="bgcolor" value="#ffffff" />

<embed src="http://servernamesharepoint/Test/TestDoclib/flashslide.swf" quality="high" bgcolor="#ffffff" name="worldtime" align="middle" allowScriptAccess="servernamesharepoint" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

</object>

Saturday, October 31, 2009

Windows 2008 Server - Deploy Dll in Gac

1. Go to start --> Command Prompt as Administrator --> "explorer %windir%\assembly"
2. Open second command prompt. Go to start --> Command Prompt as Administrator --> "
explorer [path to directory where the dll is located]"
3. Drag drop the dll from the source directory to the GAC. Thats done.

Thursday, October 29, 2009

Custom activity with full code for creating folder in list/Library with action file code

Code:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;



namespace CreateFolder
{
public partial class Activity1 : Activity
{

public static DependencyProperty FolderNameProperty
= DependencyProperty.Register(
"FolderName", typeof(string), typeof(Activity1));

[DescriptionAttribute("FolderName")]
[CategoryAttribute("FolderName Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string FolderName
{
get
{
return ((string)(base.GetValue(Activity1.FolderNameProperty)));
}
set
{
base.SetValue(Activity1.FolderNameProperty, value);
}
}

public static DependencyProperty BaseUrlProperty
= DependencyProperty.Register("BaseUrl", typeof(string), typeof(Activity1));

[DescriptionAttribute("BaseUrl")]
[CategoryAttribute("BaseUrl Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string BaseUrl
{
get
{
return ((string)(base.GetValue(Activity1.BaseUrlProperty)));
}
set
{
base.SetValue(Activity1.BaseUrlProperty, value);
}
}

public static DependencyProperty ListNameProperty
= DependencyProperty.Register("ListName", typeof(string), typeof(Activity1));

[DescriptionAttribute("ListName")]
[CategoryAttribute("ListName Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string ListName
{
get
{
return ((string)(base.GetValue(Activity1.ListNameProperty)));
}
set
{
base.SetValue(Activity1.ListNameProperty, value);
}
}


public static DependencyProperty InvokeEvent
= DependencyProperty.Register("Invoke", typeof(EventHandler), typeof(Activity1));

[DescriptionAttribute("Invoke")]
[CategoryAttribute("Invoke Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public event EventHandler Invoke
{
add
{
base.AddHandler(Activity1.InvokeEvent, value);
}
remove
{
base.RemoveHandler(Activity1.InvokeEvent, value);
}
}

public Activity1()
{
InitializeComponent();
}

protected override ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext)
{
// Raise Invoke Event to execute custom code in the workflow.
this.RaiseEvent(Activity1.InvokeEvent,
this, EventArgs.Empty);

string strIndrajeet = FolderName;
string strBaseUrl = BaseUrl;
string strDocLibName = ListName;

SPSite spsite = new SPSite(strBaseUrl);

spsite = new SPSite(strBaseUrl, spsite.SystemAccount.UserToken);
using (SPWeb spweb = spsite.OpenWeb())
{
spsite.AllowUnsafeUpdates = true;
spweb.AllowUnsafeUpdates = true;

SPFolderCollection folders = spweb.GetFolder(strBaseUrl + "/" + strDocLibName).SubFolders;

bool boolFolderNotCreated = true;

if (!spweb.GetFolder(strBaseUrl + "/" + strDocLibName + "/" + strIndrajeet).Exists)
{
folders.Add(strIndrajeet);
boolFolderNotCreated = false;
spweb.Update();
}

int count = 1;
while (boolFolderNotCreated)
{
string folderName = strIndrajeet + "_" + Convert.ToString(count);
SPFolder spfTemp = spweb.GetFolder(strBaseUrl + "/" + strDocLibName + "/" + folderName);
if (!spfTemp.Exists)
{
folders.Add(folderName);
boolFolderNotCreated = false;
spweb.Update();
}
else
{
count++;
boolFolderNotCreated = true;
}
}
}

// Indicate that the activity has completed.
return ActivityExecutionStatus.Closed;
}
}
}

<strong>.Aciton file entry (under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\1033\Workflow)</strong>
<blockquote></blockquote>""""


<workflowinfo>
<actions parallel="and" sequential="then">
<action category="List Actions" appliesto="all" assembly="CreateFolder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=effbcf4c7d0dab8e" classname="CreateFolder.Activity1" name="Create Folder">
<ruledesigner sentence="Create Folder in List %2 with folder name %1 under site %3">
<fieldbind id="1" designertype="TextArea" field="FolderName">
<fieldbind id="2" designertype="TextArea" field="ListName">
<fieldbind id="3" designertype="TextArea" field="BaseUrl">
</ruledesigner>
<parameters>
<parameter name="FolderName" direction="In" type="System.String, mscorlib">
<parameter name="ListName" direction="In" type="System.String, mscorlib">
<parameter name="BaseUrl" direction="In" type="System.String, mscorlib">
</parameters>
</action>
</actions>
</workflowinfo>

<strong>Web.Config Entry</strong>
<authorizedtype assembly="CreateFolder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=effbcf4c7d0dab8e" authorized="True" typename="*" namespace="">