Ideas for Free

Ideas for Free

only freedom gives SharePoint real power to grow

Ideas for Free RSS Feed
 

Archive for SharePoint

Microsoft SharePoint Administration Toolkit the 4th

English

Today, I almost missed an update of very nice tool – Microsoft SharePoint Administration Toolkit. I browse to Microsoft SharePoint Team Blog, – found out that they already announce the 4th release last week.

But before you can play around with the tools, you will need to install following pre-requisites:

  1. Service Pack 2 for WSS and SharePoint Server 2007
  2. April Cumulative Update for WSS and SharePoint 2007.

The April CU comes as hotfix – so you will need to register your email address and get the download link + password from your inbox.

Since its almost late for me, I think – I will continue the installation tomorrow, after downloading the package.

Check here for more details :
1. April CU : http://blogs.msdn.com/sharepoint/archive/2009/05/13/april-cumulative-update-packages-ready-for-download.aspx

2. Microsoft SharePoint Administration toolkit:
http://blogs.msdn.com/sharepoint/archive/2009/08/27/announcing-the-fourth-release-of-the-microsoft-sharepoint-administration-toolkit.aspx

SPD: How to change 24hr format to 12hr format AM/PM

English

I’ve found this question in forum – but since it was not easy to explain by sentences, I would like to create a sample working option here.

For example you have this list as data source:

9-4-2009 7-30-07 AM

In the data source you have 24hr format (I use string type for my sample, but you can use normal DateTime).

In SharePoint, to display the 24hr format in 12hr format, you need to use DataFormWebpart + proper ddwrt function like this:

9-4-2009 7-58-28 AM

The ddwrt function you need to play is:

ddwrt:FormatDate(string([Field]),1033,5)

[Field] is the field where you have the data, in this case internal name of “24hr format”.
1033 is the culture
5 is the predefined format , you can use ‘M/d/yyyy hh:mm:ss tt’ instead.

 

And the final result will be,

9-4-2009 8-02-18 AM

 

Happy design!

Semantic URLs for SharePoint

English

First time I understand about semantic URL is when I started to create my blog. According to the Wikipedia, ”Semantic URL” refers to a URL which is of a form that is immediately and intuitively meaningful to non-expert. For example,  if we refer to a publishing pages in SharePoint , we might see http://<someserver>/<somedepartment>/pages/default.aspx , or http://www.mycompany.com/hrdepartment/pages/policy.aspx which are not intuitive.

To make it easier for non SharePoint expert, one would love to remember semantic urls such as http://www.mycompany.com/hrdepartment/policy which then redirect to actual page under pages library in SharePoint.

Waldek has post excellent how-to , to create semantic URL in IIS-7 in his blog here. However, I wonder if we could do the same (without create single line of code) in IIS-6.

Problem when installing WSP in Windows 7/Windows Server 2008

English

I know that Microsoft has fabulous 40, a collection of 40 site templates in this link. I have played with all the templates, without any problem – but today when I tried to install it in my Windows 2008 server I was stuck in the wsp deployment. It seems that I couldn’t deploy the WSP.

Then, I remembered that Windows 2008 has increased security model which prevent accidental execution using privileged account. So, what I did to solve it – was just simply open the cmd console using privileged account.

Right click on “cmd.exe” and select “Run as Administrator”. And here we go, all wsp finally deployed to my MOSS installation.

Howto: Use lambda expression in SharePoint – Working with SPWeb

English

Before you continue reading this post, I hope you have read the basic task to start using lambda expression in SOM here.

A.  Find any Event list in site.

SPWeb spWeb = SPContext.Current.Web

var lists = spWeb.Lists.OfType<SPList>().Where(
             l => l.BaseTemplate == SPListTemplateType.Events);
  foreach (SPList list in lists)
{
       Console.WriteLine("{0} {1}", list.BaseTemplate.ToString(), list.Title);

  }

B.  Find any list based on custom list definition with Type=20080

SPWeb spWeb = SPContext.Current.Web

var lists = spWeb.Lists.OfType<SPList>().Where(
             l => (int) l.BaseTemplate == 20080);
  foreach (SPList list in lists)
{
       Console.WriteLine("{0} {1}", list.BaseTemplate.ToString(), list.Title);

  }

C. Find any “Daily” alert in the site

SPWeb spWeb = SPContext.Current.Web

var alerts = spWeb.Alerts.OfType<SPAlert>().Where(
                                  a => a.AlertFrequency == SPAlertFrequency.Daily);

  foreach (SPAler alert in alerts)
{
      // Do something with alert

  }

D.  Find any user which are Domain group

SPWeb spWeb = SPContext.Current.Web

var users = spWeb.SiteUsers.OfType<SPUser>().Where(
                              u => u.IsDomainGroup );

  foreach (SPUser user in users)
{
      // Do something with alert

  }

Howto: Configure personal regional setting

English

When you are working in multi-sites environment you may sometimes confused with the timestamp given by the server. The timestamp (Created Date, Modified Date) is combination of several factors :

a. Server TimeZone   , is physical server timezone configuration.
b. Web Application TimeZone , is application level timezone configuration.
c. Site   , is subsite, web timezone configuration.

How would you make sure that you are working on correct timezone in SharePoint? This post will explain how to configure personal regional settings.

1. Click on Logon User menu, and select My Settings
TZ_2

 

2. On the User Information page, click on “My Regional Settings”
TZ_3

 

3. On Regional Settings page, uncheck “Always follow web settings” and configure your personal Time zone setting and click OK.

TZ_4

4.Sample of same page with different time zone configuration

   Original view.
   Website timezone : GMT+7
   Webserver timezone : GMT+8
   Client timezone        : GMT+8

TZ_1 

 

   After configuring regional setting view.
   Website timezone : GMT+8
   Webserver timezone : GMT+8
   Client timezone        : GMT+8

   TZ_6

So, don’t be fooled by website timezone configuration.

Howto: Limits PageLayouts availability in Create Page

English

When you start to create a page, you will be presented a Create page form. In that page, you will have opportunity to select the page layouts for the new page. This howto will describe how to limits page layouts availability in create page. 

See picture below, instead of having all page  layouts listed – we only have 3 page layouts related to the site.

5-6-2009 10-54-32 AM

Howto:

1. Open Site Settings, and click on “Page layouts and site templates”

5-6-2009 10-43-43 AM

 

2. Select “Pages in this site can only use the following layouts:” and subsequently select the page layouts for current site.

5-6-2009 10-53-33 AM

3. Click “OK” to apply your changes.

Howto: Use lambda expression in SharePoint Object Model – Working with WebApplication

English

Before you continue reading this post, I hope you have read the basic task to start using lambda expression in SOM here.

A. Find existing job definition, named “Change Log”

SPWebApplication spWebApplication = SPContext.Current.Site.WebApplication;
var jobs = spWebApplication.JobDefinitions.Where(x => x.Title == "Change Log");
foreach(SPJobDefinition job in jobs)
               Console.WriteLine(job.Id);

B. Find existing custom job definition MyCustomJobDefinition, named “My Custom Job”

SPWebApplication spWebApplication = SPContext.Current.Site.WebApplication;
var jobs = spWebApplication.JobDefinitions.OfType<MyCustomJobDefinition>().Where(x => x.Title == "My Custom Job");
foreach(SPJobDefinition job in jobs)
               Console.WriteLine(job.Id);

C. Find site collection from “STS” template

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

var allSPSite = webApplication.Sites.OfType<SPSite>().Where(s => s.RootWeb.WebTemplate.Equals("STS", StringComparison.InvariantCultureIgnoreCase));

foreach(SPSite spSite in allSPSite)

{

      // operation in the SPSite

}

D. Find All RootWeb (of Site collection)

SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;
var rootWebs= spWebApplication.Sites.OfType<SPSite>().Select ( s => s.RootWeb );
foreach (SPWeb spWeb in rootWebs)
{
   // Do your task here
}

E. Find if Site Collection with RootWeb contains list named “Sample List”

SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;
var sites = spWebApplication.Sites.OfType<SPSite>().Where(
                    s => s.RootWeb.Lists.OfType<SPList>().Where(
                         l => l.Title.Equals("Sample List",StringComparison.InvariantCultureIgnoreCase)).Count() > 0);
foreach (SPSite spSite in sites)
{
   // Do your task here
}

F. Find if RootWeb which contains list named “Sample List”

SPWebApplication spWebApplication = SPContext.Current.Site.webApplication;

var rootWebs = spWebApplication.Sites.OfType<SPSite>().Select(s => s.RootWeb).Where(
                                 r => r.Lists.OfType<SPList>().Where(
                                     l => l.Title.Equals("Sample List",StringComparison.InvariantCultureIgnoreCase)).Count() > 0);

foreach (SPWeb spWeb in rootWebs)
{
   // Do your task here
}

Howto: Use lambda expression in SharePoint Object model

English

Lambda expression has been introduced since .NET framework 3.5, it is an anonymous function that can contain statement and expression. For more understanding on lambda expression you can read directly in MSDN page here. I will assume that you have read the topic and you can remember the lambda simply as:

(input parameters ) => operation

We will start with very basic operation of using lambda expression in SOM, and I hope you’ll find your path for more complex one. (note some code may not be efficient, for the clarity purpose)

A.  Start with OfType<TResult>() function to get IEnumerable that implement query pattern.

Example:

Originally to browse to all Site collection in WebApplication we will write,

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

SPSiteCollection allSPSite = webApplication.Sites;

foreach(SPSite spSite in allSPSite)

{

      // operation in the SPSite

}

the equivalent for our lambda starter is,

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

var allSPSite = webApplication.Sites.OfType<SPSite>();

foreach(SPSite spSite in allSPSite)

{

      // operation in the SPSite

}

B. Use lambda expression in the IEnumerable

Example :

You need to list all Site collection which uses STS site template.

Originally you will write,

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

SPSiteCollection allSPSite = webApplication.Sites;

foreach(SPSite spSite in allSPSite)

{

      if(spSite.RootWeb.WebTemplate.Equals(“STS”,StringComparison.InvariantCultureIgnoreCase))

     {

           // Do operation in selected site

     }

}

the equivalent using lambda is,

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

var allSPSite = webApplication.Sites.OfType<SPSite>().Where(s => s.RootWeb.WebTemplate.Equals("STS", StringComparison.InvariantCultureIgnoreCase));

foreach(SPSite spSite in allSPSite)

{

      // operation in the SPSite

}

Ok, now I believe you will get the idea of how to use lambda expression in SOM collection. In next posting, I’ll cover directly to the sample usage of the lambda.

SSP: How to add new profile property mapping

English

When you work with Microsoft Office SharePoint Server (MOSS 2007), you’ll find that one of its component is User Profiles synchronization. The User Profiles synchronization is maintained by Shared Service Provider (SSP). It synchronized MOSS user profile with Active Directory profiles.

There are around 46 predefined profile with 21 are mapped to AD property.

Some of you might have an idea that you can add the new profile or change how it mapped to AD property. But how would you do it? Its not complex task, but I would like to make it graphical how-to.

1. Open SSP Administration page and click on User profiles and properties.

5-5-2009 10-52-26 AM

 

2. On “User profiles and properties” page, click on “Add profile property”

 5-5-2009 10-53-23 AM

3. On “Add user profile property” page, define the new profile. I put yellow mark on the important things,

- Name              : Fieldname for new profile property

- Display Name   : Display name for new profile property

- Type               : Field type

- Source Data Connection : Profile property mapping definition

5-5-2009 10-55-14 AM

4. Finally, after you define the mapping in “Source Data Connection” you can click OK. Do full import to update current profiles with the new profile property.

Computers Business Directory - BTS Local