Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Tuesday, April 2, 2013

Apps for SharePoint : Map App (Bing Maps inside SharePoint) v1.0.0.2

Map App version 1.0.0.2 has been released. This version will contain the following new enhancements and new features in addition to previous version’s features.

Enhancements
  • Updated UI – Inherits the site design
New Features
  • Introducing Directions Module
    • Get Directions
    • Drag and Customize the Routes
Untitled1
Updated UI
Untitled2
Updated UI
Untitled3
Updated UI
Untitled4
Updated UI - Directions Module
Untitled5
Updated UI - Directions Module (Drag)
Enjoy the app in your SharePoint 2013 environment and appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Friday, January 18, 2013

Apps for SharePoint : Map App (Bing Maps inside SharePoint) v1.0.0.1

After the initial release of “Map App”, with some major enhancements version 1.0.0.1 was released today. In this version the map control is powered with the latest Bing Maps design. In addition you will get the following new features in addition to previous version’s features.

New Features
  • Go to your favorite locations and save it in a SharePoint list.
  • View your saved locations in the map.
  • Manage locations in SharePoint List.
Untitled0
Map App
Untitled1
Search Locations
Untitled2
Add Locations
Untitled3
View Added Locationson Map
Untitled4
View Added Locations on List
Enjoy the app in your SharePoint 2013 environment and appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Wednesday, January 16, 2013

Apps for SharePoint : Map App (Bing Maps inside SharePoint) v1.0.0.0

I wanted to create an App for Office Store and Apps for sometime and thought to create an App for SharePoint which I named as “Map App”. “Map App” is mainly for searching and storing geographic locations while sitting inside SharePoint.

No offense Google, but Bing™ Maps is my favorite online mapping service and this app is developed using Bing Maps AJAX Control, Version 7.0. As this is the first version, this will only support searching for a particular location and getting the current location. Hoping to provide more features with the coming versions.
Map App v1.0.0.0 Features
Untitled4
Map App (New )
Untitled0
Map App Home
Untitled1
Get My Location
Untitled2
My Location
Untitled3
Search Location
Enjoy the app in your SharePoint 2013 environment and appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Tuesday, December 4, 2012

SharePoint 2010 : How to Create a Custom List Definition and a Instance

I will start by creating an Empty SharePoint project and I am going to deploy it as a Farm solution.
Untitled1
Empty SharePoint Project
Untitled2
Trust Level - Farm Solution
Then I am adding a SharePoint Mapped Folder to Images and I am adding a image to use as Feature Image Url.
Untitled3
SharePoint "Images" Mapped Folder
Untitled4
SharePoint "Images" Mapped Folder created
Then I am right clicking on my Project and add a new item which is a “List Definition”.
image
Add List Definition
Now I am setting the Display name of my list definition and setting up the list type as a “Custom List”.
Untitled5
List Display Name & Type

A Feature will be created in addition to my list definition. I am double clicking on the feature and in the properties I am setting up the Image Url.
Untitled6
Feature Image Url

Now I am modifying the Schema.xml file in the list definition. I am adding fields which should be included in my list.

Schema.xml
<Fields>
        <Field Name="EmpId" DisplayName="Employee Id" Type="Text"></Field>
        <Field Name="EmpName" DisplayName="Employee Name" Type="Text"></Field>
</Fields>


Since I have created an instance of my list, I am going to put some default values. I am modifying the Elements.xml of the instance.

Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="MySharePointProject - MyListInstance"
                OnQuickLaunch="TRUE"
                TemplateType="10000"
                Url="Lists/MySharePointProject-MyListInstance"
                Description="My List Instance">
      <Data>
          <Rows>
              <Row>
                  <Field Name="EmpId">1</Field>
                  <Field Name="EmpName">Jaliya Udagedara</Field>
              </Row>

              <Row>
                  <Field Name="EmpId">2</Field>
                  <Field Name="EmpName">John Doe</Field>
              </Row>

              <Row>
                  <Field Name="EmpId">3</Field>
                  <Field Name="EmpName">Jane Doe</Field>
              </Row>
          </Rows>
      </Data>
  </ListInstance>
</Elements>


Now I am deploying the solution and once it is activated, I can see my List definition is available.
Untitled12
Create New List

And I can see a quick launch item is created.
Untitled7
Created List Instance

I am getting the default view of the list instance. But as you can see the two fields I have added is not displaying here. So I am again modifying the Schema.xml file in the list definition as follows. I am deploying the solution again and now the fields are displaying.

Schema.xml
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="Attachments"></FieldRef>
      <FieldRef Name="LinkTitle"></FieldRef> <!--if you don’t want to see title, comment this line-->
      <FieldRef Name="EmpId"></FieldRef>
      <FieldRef Name="EmpName"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="ID"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
    </ParameterBindings>
</View>


Untitled9
Created List Instance
Now when I click on Add new item, only Title field is displayed and not my created fields.
Untitled8
Created List Instance
For that, I am commenting the following part in the Schema.xml file in the list definition as follows.

Schema.xml
<!--<ContentTypes>
      <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>-->


Now I can see the fully completed output.
Untitled11
Created List Instance
Happy Coding.

Regards,
Jaliya

Tuesday, November 20, 2012

SharePoint : Sandboxed Solutions vs. Farm Solutions

We are almost close to end of this year and in this year I have only wrote 6 posts in SharePoint. I have not touched any SharePoint projects for like last 10 months and now I feel like I don’t know SharePoint at all. So it’s time to start learning SharePoint again, otherwise in couple of months I will ended up being a total stranger to SharePoint.

Today I am going to write about Sandbox solutions and Farm solutions. When you are creating any SharePoint solution using Visual Studio, you are prompted to select the Trust Level of the solution which is either a Sandboxed solution or a farm solution.
Untitled
Select the Trust Level
Which is either you can deploy the solution directly into the Server farm or into a sandbox. So what really is this deploying to sandbox or deploying to server farm? We are about to find it out.

Sandboxed Solution


Before learning what is a Sandboxed solution, we should learn what is a Sandbox. A sandbox is a testing environment that enables programs to access only certain resources, and that keeps problems/issues that occur in the sandbox from affecting the rest of the server environment. Basically what it does is sandbox isolates untested code from the working environment.

So when we are deploying a solution as a sandboxed solution, the solution  cannot access content outside the site collection they are deployed in. The sandboxed solution will not be able to use certain computer and network resources. Since the sandboxed solution is scoped to the site collection, we don’t really need a farm administrator to deploy the solution. A site collection administrator can do the deployment.

Sandboxed solutions are hosted in the SharePoint user code solution worker process (SPUCWorkerProcess.exe). Because sandboxed solutions do not run in the IIS worker process, neither the IIS application pool nor the IIS server must restart.

Mainly we can’t create following as a sandboxed solution.
  • Application pages.
  • Visual web parts.
  • Code-based workflows.
The following is a list of the most common things a solution running inside a sandbox cannot do,
  • Connect to resources that are not located on the local farm.
  • Access a database.
  • Call unmanaged code.
  • Write to disk.
  • Access resources in a different site collection.
  • Change the threading model.

Farm Solution


The Features in farm solutions can have scope as wide as the site collection, web application, or the whole SharePoint farm. Since Farm solutions can be scoped to Farm level, we need a Farm Administrator to deploy the solution and the assemblies in the solution always run with full trust.

Unlike sandboxed solutions, Farm solutions are are hosted in the IIS worker process (W3WP.exe) and the code in the farm solutions can affect the whole farm. When you try to retract or deploy a farm solution, the whole application pool will be recycled.

Farm solutions should be used for customizations of SharePoint administrative functions, such as custom timer jobs, custom Windows PowerShell cmdlets, and extensions of Central Administration.

For more information,
     What Can Be Implemented in Sandboxed Solutions in SharePoint 2010
     Sandboxed Solutions

Hope this helps.

Happy Coding.

Regards,
Jaliya

Saturday, July 21, 2012

Microsoft SharePoint Server 2013 Preview is Released

This week Microsoft has unveiled SharePoint Server 2013 Preview along with 2013 Preview versions of Exchange, Lync, Office Web Apps Server, Project, Visio and Office Professional Plus. All these previews brings a Metro-like feel, as well as revamped touch tools intended to make it easier to use the desktop applications on a tablet.

According to Microsoft SharePoint Team Blog, here is a list of new features which are available in this new release.
  1. New SharePoint Experience - Metro Style User Experience
  2. Pervasive Social Networking - Yammer and SharePoint
  3. SkyDrive Pro - Sync and use documents offline in the Windows Explorer
  4. SharePoint Sites - View sites in one place
  5. Projects for Everyone - Task management
  6. FAST Search and Recommendations - Search with FAST
  7. Cloud App Model and Marketplace - build, buy, deploy and manage applications via the new Cloud App Model for the Office 2013
  8. Dynamic Publishing - Multi-device, Multi-lingual intranet and internet sites
  9. In-Place Governance and Compliance - New unified policy management

I have installed SharePoint 2013 and the user experience is some what different when comparing to SharePoint 2010, but it is great. It’s like Windows 8 user experience. I think it will take some time to get familiar with this new release and I am pretty sure it is worth it.

Central Administration
Team Site

For more information on all the new 2013 product preview releases, visit Try more products page.

Happy Coding.

Regards,
Jaliya

Tuesday, March 27, 2012

Who really is this farm account in SharePoint 2010

If you have been working with SharePoint and if you are reading articles related to SharePoint, this word, "Farm Account" appears a lot in them and definitely you should be familiar with it. But I am pretty sure you must be wondering where you are defining this farm account at the first place in SharePoint. Is it your domain Administrator or someone else.

This is the place where you define the farm account for your SharePoint 2010.

Specify Configuration Database Settings

Even though the SharePoint 2010 Product Configuration Wizard asks you to specify a user as a database access account, it's not just an database access account. This account is the farm account which is used as the application pool identity for Central Administration and as the process account for the Microsoft SharePoint Foundation 2010 Timer service.

The server farm account requires the domain user account permissions. But I am always granting him domain administrator's permission and of course it's not required.

After you run the SharePoint Configuration Wizard, machine-level permissions include:
  • Membership in the WSS_ADMIN_WPG Windows security group for the SharePoint Foundation 2010 Timer service.
  • Membership in WSS_RESTRICTED_WPG for the Central Administration and Timer service application pools.
  • Membership in WSS_WPG for the Central Administration application pool.

After you run the configuration wizards, SQL Server and database permissions include:
  • Dbcreator fixed server role.
  • Securityadmin fixed server role.
  • db_owner for all SharePoint Server 2010 databases.
  • Membership in the WSS_CONTENT_APPLICATION_POOLS role for the SharePoint Server 2010 server farm configuration database.
  • Membership in the WSS_CONTENT_APPLICATION_POOLS role for the SharePoint Server 2010 SharePoint_Admin content database.

After you have completed the Product Configuration Wizard and when you are logged into SharePoint, in the right top corner of the bowser if you are logged in as "DOMAIN\Administrator", you are not logged in from the farm account. It is from your domain administrators account. If you are logged in as "System Account", then it is from your farm account. Please identify the difference.

For more information on account permissions and security settings on SharePoint 2010,
     Visit

Happy Coding.

Regards,
Jaliya

Friday, February 24, 2012

Claims Based Authentication & Classic Mode Authentication in SharePoint 2010

When you are creating a new web application in SharePoint 2010, you will have to select one of these two authentication modes : Claims Based Authentication or Classic Mode Authentication.

Authentication

I was always selecting the first one not because I knew why I am selecting it, but because it's defaultly selected. So today I thought to learn about these two authentication modes and select the suitable one rather than just selecting the default option. I am writing down what I learned, so anyone who is doing the same thing like me can stop repeating it in the future.

SharePoint 2010 supports variety of authentication methods which will fall into various authentication method categories. Since I am no professional of these and these are some serious topics of their own, I will just write it this way.

Method category Authentication methods
Windows authentication NTLM
Kerberos
Anonymous
Basic
Digest
Forms-based authentication Lightweight Directory Access Protocol (LDAP)
Microsoft SQL Server database or other database
Custom or third-party membership and role providers
SAML token-based authenticationActive Directory Federation Services (AD FS) 2.0
Third-party identity provider
Lightweight Directory Access Protocol (LDAP)


In SharePoint 2010, authentication modes determine how client computers authenticate with it's resources. SharePoint 2010 supports these two authentication modes,
  1. Claims Based Authentication
  2. Classic Mode Authentication
Authentication is the process of determining whether someone or something is, in fact, who or what it is declared to be based on the user identity.In an Active Directory Domain Services (ADDS) installed environment user identity is based on a user account. You have a user account which will contain all the information of your user name, password, group membership information etc. To authenticate your account what the application would do is, it will match the information that you supplied with the information in the Active Directory.

The nice point is this. If you use Claims Based Authentication, you can use all the supported authentication methods listed in the above table. And if you use Classic Mode Authentication, you will only be able to use methods under Windows authentication category.

In Claims Based Authentication what will happen is, user obtains a security token that is digitally signed by a commonly trusted identity provider and contains a set of claims. Each claim represents a specific item of data about the user such as his or her name, group memberships, and role on the network. Claims-based authentication is user authentication that utilizes claims-based identity technologies and infrastructure. Applications that support claims-based authentication obtain the security token from the user and use the information within the claims to determine access to resources. No separate query to a directory service like ADDS is needed. Claims-based authentication in Windows is built on Windows Identity Foundation (WIF) which is a prerequisite to install SharePoint 2010.

In Classic Mode Authentication, user accounts are treated by SharePoint Server 2010 as Active Directory Domain Services (ADDS) accounts.

Hope you all got a good understanding about Claims Based Authentication & Classic Mode Authentication. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Thursday, January 19, 2012

Tool to find the error message related to Correlation ID in SharePoint 2010

In SharePoint 2010 whenever you face an error, SharePoint will display a web page with a plain error message. That is "An unexpected error has occurred." and a Correlation ID.

An unexpected error has occurred

So have you ever wondered what is "Correlation ID" and I am pretty sure that Correlation ID will not make any sense to you.

So what is this Correlation ID? In SharePoint 2010, you get a Correlation ID (which is a GUID) attached to your logs/error messages when something happens. This ID can then be used to look up that specific error from the logs.

This Correlation ID is used per request-session in SharePoint 2010, and if you are in the process of requesting some information from SharePoint and bump into some problems along the way – your Correlation ID will be the best starting point for searching for what went wrong along that request.

With the help of SharePoint 2010 Management Shell, you can examine that specific Correlation ID and find out more information about it. Since I hate to open Management Shell and run some scripts every time I ran into these type of errors, I thought of writing a simple tool which will present me the error message details when I entered a Correlation ID.

Error Message From Correlation ID

What I did was pretty simple. I have created an simple Windows Application which will invoke the SharePoint 2010 Management Shell, run the script with a given Correlation ID and return the output. It's that much easy.

You all can try this simple tool your self.
     free download

We always develop tools for others and why not develop tools for our selves to make our life easy. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Wednesday, January 18, 2012

Installed Microsoft SharePoint Server 2010 on Windows 7

Last week I have installed Microsoft SharePoint Foundation 2010 on Windows 7. For the last two days I was thinking why not give a try to install SharePoint Server 2010 and today I installed SharePoint Server 2010 Enterprise on my Windows 7.

I removed SharePoint Foundation 2010 and installed the SharePoint server. Installation went smoothly, and I was following the steps which was on my previous post about Installing Microsoft SharePoint Foundation 2010 on Windows 7.

SharePoint Server 2010 on Windows 7

Happy Coding.

Regards,
Jaliya

Friday, January 13, 2012

Installing Microsoft SharePoint Foundation 2010 on Windows 7

Since I am also working on Microsoft SharePoint Server and I am enjoying writing custom code for SharePoint, I always wanted to have some version of Microsoft SharePoint Server running in my physical computer. I have both Microsoft SharePoint Server 2010 and Microsoft SharePoint Foundation 2010 installed on two different virtual machines which has Microsoft Windows Server 2008 r2 running. So when I want to write some code on SharePoint, I had to switch on a virtual machine. Since my Dell has only 4GB of RAM, it takes a lot of time to switch on a virtual machine and I am lacking patience.

So I thought of installing Microsoft SharePoint Foundation 2010 on my Windows 7 Ultimate which has Microsoft SQL Server 2008 R2 already installed. First I thought it will be a easy thing, but trust me it's not sweet as it seems. So I am going to write down some few things which I am sure you will find helpful.

First thing is we need to do some changes to SharePointFoundation.exe before running it. Because when you download and run the SharePointFoundation.exe, you will see this setup error message.

Setup Error
To avoid this error, we need to modify the SharePointFoundation.exe. Let's say I have copied my initial SharePointFoundation.exe file to"C:\MySharePointFiles". We can do this by extracting the exe and changing the installation configuration file which will be in "c:\MySharePointFiles\files\Setup\config.xml".

To extract the exe, in your command prompt type,
c:\SharePointFiles\SharePointFoundation.exe /extract:c:\MySharePointFiles
Add this line inside the <configuration> tag in config.xml.
<Setting Id="AllowWindowsClientInstall" Value="True"/>
Now you will not face any setup error. Next thing to notice is when you run PrerequisiteInstaller.exe, it will say this message which is "This tool does not support the current operating system.". So we will have to install the prerequisites manually if you don't already have them.

After installing prerequisites and installing SharePoint Foundation, I started configuration wizard. I have selected "Server Farm" and selected "Complete" as my Server Type. Then after filling out next screens and when I started configuration, I got an error saying I am trying to start configuration with an local user account. It's a pretty clean error message, because I am trying to make an installation on my Windows 7 which has no Active Directory.

But there is a workaround for this problem. That is with the help of SharePoint 2010 Management Shell which was installed during SharePoint Foundation installation. Open SharePoint 2010 Management Shell and run the New-SPConfigurationDatabase command with the appropriate parameters.
New-SPConfigurationDatabase -DatabaseName "SharePoint2010_Config" -DatabaseServer "Ravana" -AdministrationContentDatabaseName "SharePoint2010_Admin_Content" -Passphrase (ConvertTo-SecureString "P@ssw0rd" -AsPlaintext -Force) -FarmCredentials (Get-Credential)
This command will prompt you a Window PowerShell Credential Request to enter your username and password. Make sure to enter the username as "computername\username". Then  I got this error,
New-SPConfigurationDatabase : Could not load file or assembly 'Microsoft.Identi
tyModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
At line:1 char:28
+ New-SPConfigurationDatabase <<<<  -DatabaseName "SharePoint2010_Config" -Data
baseServer "Ravana" -AdministrationContentDatabaseName "SharePoint2010_Admin_Co
ntent" -Passphrase (ConvertTo-SecureString "P@ssw0rd" -AsPlaintext -Force) -Far
mCredentials (Get-Credential)
    + CategoryInfo          : InvalidData: (Microsoft.Share...urationDatabase:
   SPCmdletNewSPConfigurationDatabase) [New-SPConfigurationDatabase], FileNot
  FoundException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPCon
   figurationDatabase
It says it can't load the assembly "Microsoft.IdentityModel". I examined my assembly directory which is "C:\Windows\assembly". Microsoft.IdentityModel assembly was already there. Then what I did was pretty simple. I removed the Windows Identity Foundation I already had and installed the appropriate file I got downloaded from following link and restarted the machine.
     Download Windows Identity Foundation

Now again I ran the above SharePoint 2010 Management Shell command, and now the command got completed successfully. Then I started the configuration wizard again and this time it went smoothly and completed.

After successful configuration, I thought of creating a new web application from my SharePoint 2010 Central Administration. When I went to Manage Web Applications page and for my surprise "New" in the ribbon was disabled. I ran my browser as administrator and it was still disabled. To fix this what I did was "changing user account control settings to never". You can do that by going through,
control panel->user accounts->change user account control settings->never 
And now everything was perfectly working. Hope you found this post helpful. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Friday, October 21, 2011

Successfully completed a SharePoint 2010 Farm Restore

Today, I feel happy because today I did a successful and a complete SharePoint 2010 Farm Restore. And that is on a different server machine and on a different SQL Server from where the backup was taken. I have restored Site Collection backups couple of times before, but not a full farm.

When you are restoring a SharePoint farm in a separate server, there will be some major points that you might want to consider. Your server name might be different. Your domain might be different. And most importantly, when your SQL server which you are going to do the restore on is different from the SQL server where your backup was taken, you will have to do the restore process in a very careful manner.

Since I don't trust this method of doing the restore using SharePoint 2010 Central Administration, I have used SharePoint 2010 PowerShell. Using commands we can fully customize the restore options and I should tell you that it saved my day.

Happy Coding.

Regards,
Jaliya

Tuesday, June 14, 2011

Business Connectivity Services in SharePoint 2010 Explained

Business Connectivity Services in SharePoint 2010 can be defined as the big brother of Business Data Catalog in SharePoint 2007. BCS is actually the upgraded version of Business Data Catalog in SharePoint 2007. The weaknesses of BDC in SharePoint 2007 are, BDC was mainly used to access the external data. Updating the extenal data was extremely difficult with BDC and what most people say is it is near to impossible.

But with BCS in SharePoint 2010, what Microsoft has does is it let you connect to any external data source which can be either external SQL Server, Windows Communication Foundation (WCF) Service or basically all other external data sources which supports Open Database Connectivity (ODBC) Service. What ODBC is, ODBC refers to a software API method to use with Database Management Systems. Main feature of ODBC is, it is independent of programming language and operational system and so it can be used to access different database systems. To connect to a other database, ODBC defines a connection. Connection is created to define a connection between a computer and a database stored on another system. The ODBC connection contains information needed to allow a computer user to access the information stored in a database that is not local to that computer.

The main key feature of BCS is, with SharePoint 2010 every SharePoint site can access and manipulate external data within SharePoint. When you retrieved data from external data source and the moment that you make changes to those data and update them, the changes will be reflected in the external data source.

Now I will describe the Business Connectivity Services Architecture in SharePoint 2010. Take a good look at the following image. I will explain what every component does in this architecture.


Things to Note

Please note that in SharePoint 2010, BDC refers to Business Data Connectivity and not Business Data Catalog in SharePoint 2007.

  • BDC Metadata Store
The BDC Metadata Store provides storage for a collection of external content types, each of which describes how to connect to the external store. The Metadata Store acts as part of the services layer. External content types are a fundamental building block of BCS.
  • BDC Runtime
The BDC Server Runtime understands how to reach into the back-end store and connect to data based on the external content types defined within the content type store. It’s important to note the new usage of the acronym BDC to refer to the set of services that provides connectivity that is a component of BCS.
  • Security
BCS provides integration with the Secure Store Service (SSS), as well as enabling your own security model. The Secure Store Service stores credentials in database(User Name and the Password) to authorize access to shared resources. SharePoint 2010 using the Secure Store Service to store and retrieve credentials to access external data sources.
  • Solution Packaging
Solutions built with BCS can be packaged as a Visual Studio Tools for Office (VSTO) package to be delivered to a rich client, including SharePoint Workspace, Outlook and Word. BCS also exposes APIs to extend solution packaging to target additional clients.
  • Out of Box UI
BCS carries forward the ability to display external data through a Web Part UI and provides deeper integration through the addition of external lists.
  • BDC Client Runtime
A symmetrical runtime is provided for client and server, enabling you to take solutions offline with a client-side cache and to connect and push changes back to the server in a consistent manner. Use of the BDC Client Runtime enables offline operations, interacting with the external data cache.
  • Design Tools
SharePoint Designer provides a wealth of out-of-box functionality for creating BCS solutions, including the ability to define external content types and external lists, and to define InfoPath forms to surface the data to create simple solutions. Visual Studio provides the ability for the professional developer to extend those capabilities to create advanced solutions while leveraging the existing framework. 
  • Cache
client-side cache provides the ability to sync changes to and from the client-side application with the external data source.

I hope you all got a some idea about how BCS in SharePoint 2010 works. Feel free to correct me if I am wrong with anything.

Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Everything about SPQuery Class

Every kind of Application or System no matter whether they are simple or complex, they needs their data to be stored in someplace. It can be either a Database, a XML file or simply a text file. And all those applications uses CRUD (Create,Read,Update,Delete) operations to maintain their data. So in SharePoint, one of the major way of Reading or Selecting data is using SPQuery Class in Microsoft.SharePoint Namespace.

Today I am going write about this SPQuery Class. The SPQuery Class is used to represent a query in the list view. Assuming you all know about SQL Select queries, to give you some basic idea on what SPQuery do is, It does what Select query in SQL does but syntaxes are totally different. Since I am hoping to write some examples using SPQuery, I think as we go along with this post you will definetely be able to identify the differences.

Then let's start. I will be using a custom list called Customer List. It contains following columns.
  1. Title - string
  2. Name - string
  3. Field1 - Number
  4. Field2 - Number
First of all, I will write a full simple example. Follwing code will retrieve all the items in the "Customer List" in which Name field equals to "Jaliya Udagedara".

using (SPSite oSPSite = new SPSite("http://ravanaserver/"))
{
     using (SPWeb oSPWeb = oSPSite.OpenWeb())
     {
           oSPWeb.AllowUnsafeUpdates = true;
           SPList oSPList = oSPWeb.Lists["Customer List"];

           SPQuery oSPQuery = new SPQuery();
           
           // your query writes here
           oSPQuery.Query = "<Where><Eq><FieldRef Name='Name'/><Value Type='Text'>Jaliya Udagedara</Value></Eq></Where>";
           SPListItemCollection oSPListItemCollection = oSPList.GetItems(oSPQuery);
           foreach (SPListItem item in oSPListItemCollection)
           {  
                // your code
           }
     }
}

Now I will write example for common scenarios. When modifying, modify only the part where I have put comment "// your query writes here".

  • Retrieve all Items.
    • For this you don't have to write any query. Just modify the above code as follows. This will return the all Items.
           SPQuery oSPQuery = new SPQuery();
           SPListItemCollection oSPListItemCollection = oSPList.GetItems(oSPQuery);

  • Retrieve items that a field matches a given value.
           oSPQuery.Query = "<Where><Eq><FieldRef Name='Name'/><Value Type='Text'>Jaliya Udagedara</Value></Eq></Where>";

  • AND Operator - Retrieve items that matches the following condition,
                                      (Field1 >= 500) AND (Field2 <= 1000)

           oSPQuery.Query = "<Where><And><Geq><FieldRef Name='Field1'/><Value Type='Number'>500</Value></Geq><Leq><FieldRef Name='Field2'/><Value Type='Number'>1000</Value></Leq></And></Where>";

  • OR Operator - Retrieve items that matches the following condition,
                                      (Field1 >= 500) OR (Field2 <= 1000)

           oSPQuery.Query = "<Where><Or><Geq><FieldRef Name='Field1'/><Value Type='Number'>500</Value></Geq><Leq><FieldRef Name='Field2'/><Value Type='Number'>1000</Value></Leq></Or></Where>";

  • BeginsWith, AND, Contains
           oSPQuery.Query = "<Where><And><BeginsWith><FieldRef Name='Name'/><Value Type="Text">Jaliya</Value></BeginsWith><Contains><FieldRef Name="Name" /><Value Type="Text">Udagedara</Value></Contains></And></Where>";

  • IsNull - Retrieve all items Where Name field is empty,
           oSPQuery.Query = "<Where><IsNull><FieldRef Name='Name'></FieldRef></IsNull></Where>";

I think I wrote some examples for most common scenarios. Here is a table of Comparison Operators used in SPQuery Class.

Comparison Operators
General Meaning
Eq
=
Gt
> 
Lt
< 
Geq
>=
Leq
<=
Neq
<> 
Contains
Like
IsNull
Null
IsNotNull
NotNull
BeginsWith
Beginning with word
DateRangesOverlap
compare the dates in a recurring event with a specified DateTime value, to determine whether they overlap


Things to Note

But when writing these queries there is some thing that you all should note about. That is, if your field name contains any spaces for example like "First Name", in your FieldRef Name if you put as 'First Name', you will get a error like "No Matching Field". The reason behind this is when you are leaving spaces in field names, the actual field name changes. You can get the correct field name by opening the List in InfoPath designer and referring the name in that field. For 'First Name', you might get something like 'First_x0020_Name'.

Feel free to give me your feedback.

Happy Coding.

Regards,
Jaliya