Monday, October 5, 2009

Enable Anonymous Access

How to enable anonymous access in SharePoint.

Wednesday, September 23, 2009

SharePoint workflow

Using sharepoint designer to build workflow can be the faster way to achieve yr workflow objective.

However, the drawback is that you cant deploy it into multiple list / document library

This link will give u a better overview on how to leverage on sharepoint designer to create workflow.

Wednesday, September 16, 2009

how to enable debugging mode

lIf you did customization on SharePoint before, you will encounter the case where you have no clue on how to debug your application.

You can turn on the debug mode by changing the below setting in web.config

1. CallStack="true"
2. customerrors mode="Off"
3. compilation debug="true" batch="false"

Tuesday, September 8, 2009

How to change theme when new site is created

Some of you have this requirement to create a new theme for your customer. And obviously this theme will be used automatically if a new site is created.

One of the stupid way is to include the step to change the theme as part of the operating mannual, but let me show you the tricks.

If you understand the concept of branding on how to change the .master page, you will find this theme changer feature is very similar.

What you need to do is to :
1. Create a new theme (i.e. NewTheme) and put it in 12hive\ Themese folder
2. Create a new .vb file which inherit SPFeatureReceiver and override FeatureActivated method to include the below coding.

Dim objWeb As SPWeb
objWeb = properties.Feature.Parent
objWeb.ApplyTheme ( " NewTheme " )
objWeb.Update()

3. The above is to ensure that newtheme is being switched when the code is feature is activated.
4. Compile it with strong name and deploy to GAC.
5. Package this .dll as feature
6. Locate the onet.xml for site template that you have 12hive\template\sitetemplates\SITE NAME\xml
7. locate to include the feature ID which you have created earlier.

The idea of this theme changer is very similar to branding.

Wednesday, July 15, 2009

SharePoint RSS

SharePoint RSS provides the flexibility to expose view as RSS feed. With this feature, we can perform filtering, grouping and etc. to aggregate the list data information in the list and expose it as RSS feed.

Follow this article to achieve it.

Tuesday, July 14, 2009

Survey on Publishing template for anonymous

You might experience access denied behaviour when you try to use anonymous access to response survey.

How this happen is because a feature called ViewFormPagesLockDown is activated for publishing site.

So the key is to deactivate this.

stsadm -o deactivatefeature -name ViewFormPagesLockDown -url yrURL

find out more from here

Wednesday, July 8, 2009

Good Architect for DAL

I came across a very structure way to populate data from database back to object class.

After we retrieve data from database, typically we will have a datareader object. We can leverage on the method below to convert dr value to match with the data type in object class.

protected T GetDataObjectValue(IDataReader dr, string columnName)
{
int i = dr.GetOrdinal(columnName);
if (!dr.IsDBNull(i))
return (T)dr.GetValue(i);
else
return default(T);
}


Next, we can build a function to load the value into object class like below:

obj.ID = base.GetDataValue(dr, "ID");

If required, we can add the object into a object List.

Thursday, July 2, 2009

Infopath Best Practice

Infopath Deployment Best Practice

infopath limitation

It is very important to understand the limitation of infopath 2007. From high level, web based infopath is very powerful but it comes with several limitations.

  1. No native write to SQL databases. The ease of use of establing an ADO connection to SQL or Access, and being able to query and write back to a database is lost. Instead you will probably need to talk to the DB via a web service.
  2. No roundtripping for cascading picklists. Something I do all the time is have one picklist be a filter for another picklist. Common example, pick a state, which then filters the city field dropdown. Can't do that in a web form.
  3. Summary list of controls that aren't supported in web forms:
    ComboBox,Multiple-Selection List Box
    Master/Detail,Bulleted, Numbered and Plain List
    Picture ,Ink Picture ,Vertical Label
    Scrolling and Horizontal Region ,Horizontal Repeating Table
    Choice Group ,Repeating Choice Group
    Choice Section ,Repeating Recursive Section
    ActiveX Controls

Refer to this article for more details, MSDN article.

With this limitation, this shows you how to perform debugging.

Wednesday, July 1, 2009

Email Regular expression validation

Email regular expression validation

([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])(([\w\-]+\.)+)([a-zA-Z]{2,4}))

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.

Friday, May 29, 2009

Form Based Authentication (FBA) in Sharepoint

The default authentication in sharepoint is Active Directory. In cases when you have a internet portal where your user is mainly from internet, you might consider to use Form based authentication. This is not an uncommon scenario.



The good news is, it is possible to leverage on the existing ASP.NET Membership provider in .net framework 2.0 onwards. The next question will be HOW TO do it ...



1. Create membership provider database by executing [aspnet_regsql.exe] from [C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727]



2. Give a name for the database, it is always better not to use the default name to avoid conflict of database, and continue the wizards to create the tables, stored procedures needed for membership providers



3. After you created the database, you need to add your first user. There are two ways:

a. Execute



declare @now datetimeset

@now= GETDATE()

exec aspnet_Membership_CreateUser '/', 'userlogin','password','','email@somewhere.com','','',1,@now,@now,0,0,null



b. Use VS to modify the ASP.NET Web configuration


4. Append three sections in web application web.config

<>

< name=" FBAConnectionString " connectionstring=" Data Source=.;Initial Catalog= MOSS_FBA;Integrated Security=True ">

< / connectionStrings >

< defaultprovider= " FBAMember ">

<>

< connectionstringname= " FBAConnectionString " enablepasswordretrieval=" false " enablepasswordreset=" true ">

requiresQuestionAndAnswer=" false "

applicationName="/"

requiresUniqueEmail="false"

passwordFormat=" Hashed "

maxInvalidPasswordAttempts="5"

minRequiredPasswordLength="1"

minRequiredNonalphanumericCharacters="0"

passwordAttemptWindow="10"

passwordStrengthRegularExpression=""

name="FBAMember" type="System.Web.Security.SqlMembershipProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" /> < / providers >< / membership >


< mode=" Forms ">

< / authentication >

<> <> < key="FBAMember" value="%"> < / PeoplePickerWildcards >


5. Make the same changes in web.config for central admin

6. Central Admin --> Application Management --> Site Collection Owner, Add the user that you created in step 3

7. Central Admin --> Application Management --> Authentication Providers , you should see two entry. Click on the default zone.

8. Change the authentication to 'FORM' and update the Membership provider name:
9. You should be able to login now.

Wednesday, May 27, 2009

Sharepoint 2007 Boundaries (limitation)

It is always important to understand the limitation or boundary of the system. For example, you cant be creating item in the list without any limit.

Check it out from here

It provides you a better idea on how to plan your system

Sunday, May 24, 2009

Sharepoint content publishing

One of the key feature in sharepoint is about content publishing, which means it provides you the flexibility to separate authoring and publishing environment.

Then you may ask one question. HOW TO DO IT !!!

It is very simple, just follow the steps below:

On Target
1. Create a new web application in target.
2. Create a empty site, preferably using
stsadm -o createsite -url http://targetSiteUrl/ -ownerlogin yrLogin -owneremail yrEmail
--If you dont use blank site, you are expected to see error
3. Then you should go to central admin --> Operation --> Content Deployment Settings to turn on "Accept incoming content deployment jobs"

On Source
1. Go to central admin --> Operation --> Content Deployment Paths and jobs
2. Create new path
3. Create new job
4. Execute the job

One very important notes !!!
If you have feature deployed on the source, MAKE SURE YOU HAVE IT INSTALL IN TARGET AS WELL before the deployment started.

Some basic readings that you might want to start off before you perform publishing deployment
1. Basic Idea
2. Basic Walkthrough
3. Pre-deployment
4. Best Practice

Friday, May 22, 2009

Sharepoint Timer Error

After you deploy the solution file and when you try to deploy the solution, you see the following error message.

You should check your [Windows Sharepoint Service Administration] if it is activated. !!! After you activated the service, make sure you run the command below to execute the timer job directly instead of wasting your time to wait for sharepoint to pick up the job.

STSADM –O execadmsvcjobs

The timer job for this operation has been created, but it will fail because the administrative service for this server is not enabled. If the timer job is scheduled to run at a later time, you can run the jobs all at once using stsadm.exe -o execadmsvcjobs. To avoid this problem in the future, enable the Windows SharePoint Services administrative service, or run your operation through the STSADM.exe command line utility

Wednesday, May 20, 2009

List Deleting event

Surprise to see this, but I'm going to disappoint you. Sharepoint does not provide any list deleting event. In fact, there is no event for list creation, deletion events.

One possible workaround that i found from sharepointking is to make use of itemDeleting events.

When list is deleted, itemDeleting event will be triggered. And the ListItem id will be 0.

Monday, May 18, 2009

How to activate a feature when site is created

If you have a feature that can only be activated in web level and you need the feature to be activated when the site is created, then you might need to read the following.

The key word is feature stapler, which allows you to tight a feature that you need to activate to a site template.

In summary,
1. you create a new feature that set the scope to "farm" level
2. in the element.xml, you create


FeatureSiteTemplateAssociation Id="2B3451F0-BC93-41A4-9FAD-3A81861D651A" TemplateName="STS#0"/
2B3451F0-BC93-41A4-9FAD-3A81861D651A : feature to be activated when site is created
STS#0 : STS is the template name, and 0 is the configuration ID in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

Refer to http://sharepointmagazine.net/technical/development/introduction-to-sharepoint-feature-stapling-part-1

Saturday, May 16, 2009

How to change the bloodly PAGES when you create publishing page in page library

If you realize when you use page content type, regardless of where the document library is location, the path is always pointing to PAGES folder, it makes your path become very ugly in the URL..

www.yoursite.com/site1/pages/myPage.aspx
www.yoursite.com/site1/pages/myPage2.aspx

Below article highlights on how to customize this behaviour. Instead of using the default createPage.aspx, we will change it to something else. And make modification from there.

Before you start, one point to take note, YOU MUST ADD THE FOLLOWING NAMESPACE IN THE NEW PAGE ELSE YOU WILL SPEND HOUR ON DEBUGGING

Import Namespace="Microsoft.SharePoint.Publishing"


<%@ Import Namespace="Microsoft.SharePoint.Publishing" %>

http://blogs.msdn.com/syedi/archive/2008/07/18/why-should-one-save-publishing-pages-in-pages-list-always-in-moss-bend-it.aspx

Tuesday, May 5, 2009

List Template Id's

850 Page
100 Generic list
101 Document library
102 Survey
103 Links list
104 Announcements list
105 Contacts list
106 Events list
107 Tasks list
108 Discussion board
109 Picture library
110 Data sources
111 Site template gallery
112 User Information list
113 Web Part gallery
114 List template gallery
115 XML Form library
116 Master pages gallery
117 No-Code Workflows
118 Custom Workflow Process
119 Wiki Page library
120 Custom grid for a list
130 Data Connection library
140 Workflow History
150 Gantt Tasks list
200 Meeting Series list
201 Meeting Agenda list
202 Meeting Attendees list
204 Meeting Decisions list
207 Meeting Objectives list
210 Meeting text box
211 Meeting Things To Bring list
212 Meeting Workspace Pages list
301 Blog Posts list
302 Blog Comments list
303 Blog Categories list
1100 Issue tracking
1200 Administrator tasks list

Sunday, May 3, 2009

6 pillars of MOSS

Before anyone starts to do / sell sharepoint. The person should understand the 6 pillars of MOSS.

1. Collaboration
2. Portal
3. Search
4. Content Management
5. Business Process
6. Business Intelligence

1. Collaboration
How does your organization share information ? In shared folder or riding on a custom built web page. With MOSS, you can have a better knowledge management by leverage on Wikis, Workspace, Forum and etc. These are out of the box feautes provided by MOSS.

2.Portal
Any enterprise should have a one corporate website to deliver information to the employee. Apart from the information delivering, MOSS can seamlessly integrate with various systems like SAP, oracle to make MOSS a one stop website for everything. For example, if you are using Oracle Siebel CRM to store your customer information, you dont have to login to Siebel system to see your customer list. You can view them from MOSS page.

3. Search
If you have tons of information and it is not accessable, these information will become useless. It is important to be able to search information with just a few clicks. And this feature is provided out of the box from MOSS.

4. Content Management
In this fast pace environment, how fast you response to the opportunity is the key differentiator for your competitors. With MOSS you can manage your website content as easy as a few clicks.

5. Business Process
Typical enterprise environment will need forms submission and workflow for approval. MOSS is built to integrate with various MSFT office products including Infopath, which allows you to fill in information and ready for submission. And form submission, workflow (both standard and customized build) can be activated to perform the tasks that is needed. For example, for leave application, employee can fill in the pre-designed form in infopath. After the form is submitted, approval workflow can be triggered for manager approval.

6. Business Intelligence
How do you capitalize your data is to gain a bigger market share is very important. With MOSS, you can integrate with SQL Reporting services easily (SSRS), you prepare report in various formats. On top of that you can also leverage on the datamining feature in SSRS.

Good Startup for MOSS

You will find very interesting MOSS related topic here, to avoid tons of words to start with, this is a very good material from MSFT for beginner.

2007 Office System: How Do I? (ScreenCasts)

Office 2007 Partner Technical Readiness Training Presentations

After seeing these videos, you should have a better understanding on MOSS

Wednesday, April 22, 2009

How to override existing behaviour in list,site....

You can follow the below URL to create and deploy a custom event handler

1. Create basic event handler
http://msdn.microsoft.com/en-us/library/ms437502.aspx

2. custom Event Handler Deployment using Feature..
You need two files.
-Feature.xml
-Elements.xml

http://msdn.microsoft.com/en-us/library/ms475328.aspx

adding an entry to user field

Those have spent hour to figure why the list does not store login name directly will know extra effort is required to get / set username from / to user field. In fact, it is stored in the following format:

ID ;# account name

In this case, you need the following code snippet to insert very into user field with the help of SPFieldUserValue


using (SPSite site = new SPSite("http://portal"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Example For Users"];
SPListItem item = list.Items[0];

SPFieldUserValue userValue = new SPFieldUserValue(web, web.CurrentUser.ID, web.CurrentUser.LoginName);
item["User Name"] = userValue;
item.Update();
}
}

Get a user from a list item

Very often we need to obtain username or group name from the list which has column type set to "person and group". The below code snippet might be handy



using (SPSite site = new SPSite(http://mysite))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["myList"];
SPListItem item = list.Items[0];

SPFieldUserValue userValue = new SPFieldUserValue(web, item["User Name"].ToString());
if (userValue.User.LoginName == web.CurrentUser.LoginName)
{
//current user found in the list
}
}
}