Tuesday, September 29, 2009

Using sharepoint webcontrols for desinging forms

I prefer using share point web controls for designing share point custom aspx form as they provide extended properties and also provide look n feel similar to out of box look n feel.

Following is an useful msdn link for getting help related to controls

They are easy to brand with overall theme and master pages. following are list of few important controls

  1. Text Box -- SharePoint:InputFormTextBox
  2. Drop down -- SharePoint:DVDropDownList
  3. People Editor -- SharePoint:PeopleEditor
  4. Date Time -- SharePoint:DateTimeControl (for details on validation)
  5. Labels -- Sharepoint:EncodedLiteral
Also there are few important webcontrol that can be utilized for creating sections and aligning controls

  1. /_controltemplates/InputFormSection.ascx for Defining section
  2. /_controltemplates/InputFormControl.ascx for defining control
following is a sample ascx for above

<%@ Assembly Name="Sample, Version=, Culture=neutral, PublicKeyToken=68802d514f1e9922"
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SampleNamespace.Sample"%>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="/_controltemplates/InputFormSection.ascx"
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="/_controltemplates/InputFormControl.ascx"

<wssuc:InputFormSection Title="City" Description="Please select City." runat="server">
<wssuc:InputFormControl runat="server" LabelText="Country:" >
<SharePoint:DVDropDownList ID="cmbCoutnry" runat="server" AutoPostBack="true" />
<wssuc:InputFormControl runat="server" LabelText="City:">
<SharePoint:DVDropDownList ID="cmbCity" runat="server" />

<wssuc:InputFormSection Title="Dates" Description="Please select Dates." runat="server">
<wssuc:InputFormControl runat="server" LabelText="Start Date:">
<SharePoint:DateTimeControl ID="dtStartDate" runat="server" />
<wssuc:InputFormControl runat="server" LabelText="End Date:">
<SharePoint:DateTimeControl ID="dtEndDate" runat="server" />

Monday, September 14, 2009

How to upload a document in a document library programmatically

Recently I have encountered in a situation where I was required to upload few documents in a document library using my code. I found this fairly simple. Thanks to object model exposed by Microsoft.

Following code can be use to upload a document to document library with in specific site.

SPSite mySite = new SPSite("http://");

SPWeb spWeb = mySite.OpenWeb();

SPDocumentLibrary docLib = (SPDocumentLibrary) spWeb.Lists[""];

SPFolder folder = docLib.RootFolder;
using( FileStream fs = File.OpenRead("" ) )
SPFile file= folder.Files.Add("",fs);

I hope this will be helpful for those who wants to update documents and also needs to perform few custom actions on uploaded documents.

Sunday, September 6, 2009

Sharepoint workflow doesnt started automatically

I recently experienced this issues with my custom work flow designed using share point designer. Work flow didn't started automatically even though option was selected.

After doing a little research I found that issue was due to a security fix in WSS 3.o SP1
Therefore, after installing WSS 3.0 SP1, declarative workflows will not start automatically start if

1. The Windows SharePoint Services Web application runs under a user's domain account.
2. The user logs in by using this domain account.
3. The site displays the user name as System Account.

Wednesday, September 2, 2009

Configuring MOSS SSO Service

I was working on configuration settings for MS SSO service in MOSS. I think following information may also be useful for you.

You need to perform following simple steps for configuration of MS SSO Service.

1. Configure log on account to administrator user and run Microsoft Single Sign On Service.
2. Go to CentralAdministration->Operations->SecurityConfiguration->ManageSingleSignOn Serice.
3. Configure single sign on using available links i.e. Manage Server Settings, Manage Encrption Key, Manage Setting for enterprise application definition, Manage account information for enterprise application definition

For details please see following link

Tuesday, September 1, 2009

Sharepoint designer workflow : Getting data from user and storing it in workflow vari

Sharepoint designer workflows provide a great functionality using its out of the box activity for collecting data from user with in workflow.

When this action is used a form for getting data is created automatically as shown in images below

So if a user want to do some small customization the form will be available to him to do so.
The data collected in response to this action becomes part of task and can be used later in your flow for any decsion or can be utilized in other actions.

For e.g. I used data (comments) from user and update column of my list called comments.

This Action ask you three things

1: Data (Used for desinging question and creating form)
2: User (Used for assigning for to MOSS user)
3: Output Variable (List Item Id for fetching data later)

In my sample I clicked on data and add a field for asking comments from user. Assigned this to appropriate user and set output variable to a newly created variable collect3

I created a new workflow variable of type comments for storing user comments and add another action Set Workflow Variable for initializing my workflow variable with information provided by user.

Action set workflow variable provide two fields Workflow Variable and Value
I slected comments Varaible in workflow variable. Now real issues came when I need to pull up comments from my workflow form using list Item Id.

I performed following steps.
(Please note before moving ahead save your workflow by clicking on finish and repoen it by clicking on xoaml file)

1. Click on value
2. Selected Task in source
3. Selected Field "Rejection Reason" (This was the same field that I defined in my form earlier for collecting data from user)
4. It gives me two more option to select In Field I selected "Task:ID"
5. In Value I selected the WorkflowData -> Collect 3 (Same variable I used to kept the reference of my comments field)
as shown below

Now after defining above I managed to initialize my workflow variable with details collected from user in middle of workflow execution.