Recent Blogs

AvatarByRashid Aziz

Using join with CAML in SharePoint development

You can use the SPQuery.Join property in CAML to querying SharePoint lists data.  

The each join is represented by a join element (which is child of Joins element). You can use joins to join multiple lists or use multiple joins to the same list.  

Example:

I am going to show you how to use left outer join in CAML query.

The “EmployeeName” is a lookup field on a “Users” list. It looks up to the “ID” field of an “Employees” list. The “Employee” list in turn, has a “CountryName” field that is a lookup field to a “Countries List”. The first Join element assigns ‘employees’ as an alias for the “Employees” list. The second Join element assigns ‘employeeCountries’ as an alias to the “Countries” list. This query will define the join in parallel to the existing lookup relation between the “Employees” and “Countries” lists.

CAML Code:

<Joins>
  <Join Type=’LEFT’ ListAlias= ‘employees’ >
    <Eq>
      <FieldRef Name=’EmployeeName’ RefType=’Id’ />
      <FieldRef List=’employees’ Name=’ID’ />
    </Eq>
  </Join>
 
  <Join Type=’LEFT’ ListAlias= ‘employeeCountries’ >
    <Eq>
      <FieldRef List=’employees’ Name= ‘CountryName’ RefType=’Id’ />
      <FieldRef List=’ employeeCountries’ Name=’ID’ />
    </Eq>
  </Join>
</Joins>
AvatarByRashid Aziz

How to setup auto site deletion feature of SharePoint 2010

Step by step procedure to set SharePoint up to automatically cleans out unused sites:

Step # 1:

Central admin   navigates to    Application Management —–> Site Collections ——> Confirm site use and deletion 

Step # 2:

Choose Web Application  to be used for setup auto site deletion.

For Example: Use My Site Web Application. Then you have to check some of the given choices. Further changes can be made by choosing either Check for unused site collections, and send notices Daily/Weekly/ Monthly.

a).An e-mail notification will be send to owners of unused site collections. Send notifications 90 days after site collection creation, or use is confirmed.

b).Automatically delete the site collection if use is not confirmed delete the site collection after sending 28 notices you can change the 28 notification.

              

Also set up previously mail flow between SharePoint and your end users.

AvatarByRashid Aziz

SharePoint 2010 Server Name and Alternate Access mapping

The “Server Name” mapping and “Alternate Access” mapping are two features of SharePoint which provides to alter the URL’s returned in search results. A very common practice is used by different companies is “Internal” and “External” users. These both OOTB features are available in SharePoint 2010.

Let’s see these two mapping options in detail.

Server Name Mapping

1.   It is designed for file sharing and also for http content.

2.   You cam map any server name to anything you like (it should point to the same set of pages).

Example: If you have a site called http://info  and you want to show it as www.eblogin.com. By setting up the server name mapping, you crawling will use http://info   for indexing; the good thing is that user will only see www.eblogin.com

Alternate Access Mapping

1.   It is designed for “SharePoint” content.

2.   It is basically used for allowing you to modify the results URL’s based on the access URL’s for a site. If you have a same page, a user accessing that page internally will get the internal URL. While if the same page is access externally the user will see the external URL.

Example: If you have same SharePoint contents, the internal user will use http://InternalEblogin   to access the site (all search result are prefix with http://InternalEblogin/ …..  ), and the External users will user http://ExternalEblogin/    to access site (all search result are prefix with http://ExternalEblogin /…. ).

3.   It does not require a crawl for the setting to take effect.

4.   It will generate result based on how the site is being accessed.

5.   It will configured at farm level, now if you have more than one search service application in your farm, all of them will be using “Alternate Access mapping”

Using the combination of Server name and Alternate access mapping you can manage URL mapping in search results.

AvatarByRashid Aziz

Create meeting workspace pages programmatically in SharePoint

You can add meeting workspaces pages with the SharePoint UI and also manage them. It is also possible that you can create workspace pages programmatically.

Here is the code to do this.

Add the following references

using Microsoft.SharePoint;
using Microsoft.SharePoint.Meetings;
//Code:

string url = SPContext.Current.Site.Url;
string newPageUrl = String.Empty;
using (SPSite site = new SPSite(url))
 {
   using (SPWeb meetingWeb = site.OpenWeb())
   {
     SPMeeting meeting = SPMeeting.GetMeetingInformation(meetingWeb);
     meeting.AddPage("Eblogin Page", meeting.InstanceId, out newPageUrl);
   }
 }

Note: [“If you give instance id you can’t manage your page through UI, If you want to add page regardless of instance you can replace meeting.InstanceId with zero(0) in the AddPage() method parameters, now it will behave same to pages added by using UI and you can manage them using user interface. ”]

AvatarByRashid Aziz

Web analytics service application provisioning in SharePoint 2010

Hi, I am going to show you that how to provision web analytics service application in SharePoint 2010.

To accomplish this task you need to follow these steps

1.   Open SharePoint 2010 “Central Administration” site.

2.   Under “Application Management” select “Manage service applications”.

 

3.   Select new from the ribbon and click “Web Analytics Service Application” form the dropdown as shown below.

 

 

4. A modal dialogue will appear to create new web analytics service application.

5.   Provide the followings.

  •  Name of service
  •  Application pool name and select security account
  •  Provide database server name where the web analytics reporting and staging databases will be hosted  along with the staging and reporting databases names, and also specify the desired retention period.

6.   Click “Ok”  to provision the new web analytics service

7.   Now go back central admin and under “System Settings” select “Services on Server”.

8.   From the available services start the “Web Analytics Data Processing Service” and “Web Analytics Web Service” as shown below.

    

 

AvatarByRashid Aziz

Activate hidden Site Directory template in SharePoint 2010

If you are working with SharePoint 2010 enterprise features, You probably know that the Site Directory template is missing, The site directory is hidden because of compatibility issue while upgrading between SharePoint 2007 to 2010.

I will show you the workaround to enable it.

1.   Browse to the following path on your server  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\1033\XML 

2.   Now open “webtempsps.xml” 

3.   Find the site directory template name “SPSSITES” and change the hidden value from true to false.

<Template Name="SPSSITES" ID="34">
<Configuration ID="0" Title="Site Directory" Type="0" Hidden="FALSE" ImageUrl="/_layouts/1033/images/template_site_dir.png" Description="A site for listing and categorizing important sites in your organization. It includes different views for categorized sites, top sites, and a site map." DisplayCategory="Enterprise" VisibilityFeatureDependency="5F3B0127-2F1D-4cfd-8DD2-85AD1FB00BFC">

4.   Go to central admin and create new site collection, from the template you can see “Site directory” template under the enterprise site templates. Select this template and create new site.

 

5.   When site creation completes, go to the newly created site URL and confirm site template as you can see in below picture.       

    

AvatarByRashid Aziz

Installing collaboration portal template in SharePoint 2010

Today I am going to show you how to install Collaboration Portal template in SharePoint 2010.

This template is part of SharePoint Server (MOSS) 2007. Unfortunately in SharePoint 2010 this template has been removed. There are several templates that have been removed in SharePoint 2010, some of the templates which are removed in SharePoint 2010 are simply hidden, and the collaboration portal is one of them. You can install these hidden templates by using PowerShell.

Here is the method which I have used to install the hidden Collaboration template in SharePoint 2010.

1.   Go to Start > All programs > accessories >Windows PowerShell > PowerShell ISE (please make sure that you start PowerShell 64-bit ISE)

2.   Register the SharePoint PowerShell commands by using the following command

Add-PSSnapIn Microsoft.SharePoint.PowerShell

3.   Create new site collection based on “Collaboration template” by suing the following command in PowerShell

New-SPSite -URL http://ebloginWeb:4040  -OwnerAlias domainName\adminName -Name “ColPortal” -Template “SPSPortal#0″

 

The “SPSPortal#0″ is the code of collaboration template.

4.   Once the site is created you can go to your site link (in my case it is http://ebloginWeb:4040) and confirm it.

AvatarByRashid Aziz

SharePoint 2010 Web Analytics web part

We have many out of the box web parts in SharePoint 2010; one of them is “Web analytics” web part. It is always good to know about your site traffic and analytics report. The web analytics web part makes it easier; all you need to do is, add “Web analytics web part” on a page (find under “Content Rollup” category).

After adding the web parts goes to the web part settings and change it according to your need and press ok.

Web analytics give statistics about the followings.

Summary View: shows the summary of traffic.

Top Browser: It shows which type of browser user mostly used to get to SharePoint site.

Top Visitors:  Information about the top visitors and number on his/her page views

AvatarByRashid Aziz

Send email using SPUtility in SharePoint 2010

Sending email is a key function of enterprises solutions. Inside SharePoint collaboration environment you always need to send email from within SharePoint. For this purpose you can use SPUtility class SendEmail method.

Below is a simple example code for sending email using SPUtility.

Add namespace reference:

Microsoft.SharePoint.Utilities

//Code:

private viod SendEmail()
{
  try {
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
      using (SPSite site = new SPSite(SPContext.Current.Site.ID,
      SPContext.Current.Site.Zone))
      {
        using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
        {
         SPUtility.SendEmail(web, true, true, "info@eblogin.com",
         "Subject", "Your message body will go here");
        }
      }
    });
  }
  catch (Exception ex) {}
}

As you can see that sending email using SPUtility is straightforward, please also note the following considerations

1.   No attachment allowed

2.   Message body size cannot exceed 2048 characters.

3.   The form address will be the “Outbound Sender Address” configured in the central admin.

AvatarByRashid Aziz

Master page fly out quick launch menu in SharePoint

It is very simple to modify the appearance of “Quick launch” by setting attributes of master page. You can change attributes to collapse the menu view to heading and the fly out menu will be used to show subordinate menu items.

The menu control is defined in the default master for the website.

Here are the steps you need to perform to get the fly out quick launch menu.

1.   Open the browser and go to the site which “Quick launch” menu you want to customise.

2.   Navigate to Site actions > Site Setting > Master pages.

3.   Select the V4.masetr master page; click “Edit Document” form the ribbon.

4.   Go to <SharePoint:AspMenu id=”V4QuickLaunchMenu”  section of your page code and replace the “StaticDisplayLevels” attribute value to 1 and “MaximumDynamicDisplayLevels” attribute value to 1 as well.

 

<SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false"

DataSourceId="QuickLaunchSiteMap" UseSimpleRendering="true" UseSeparateCss="false"

Orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0"

SkipLinkText="" CssClass="s4-ql" />

 

You can see the before and after effects in the following pictures.

                      

            Before                                                                                    After