SharePoint 2007 vs SharePoint 2010 comparison

Developers, IT Pro, SharePoint, SharePoint 2010, Specifications No Comments »

Thanks to Richard Harbridge based on Microsoft documentation spread all over the Microsoft website, he accomplished to setup a very good comparison between SharePoint 2007 and SharePoint 2010.

He catagorized over Sites, Communities, Content, Search, Insights, Composites, Office 2010, Architecture, Web Services/OM, Editions and Administration.

http://www.rharbridge.com/?page_id=103

Create Additional Columns for a Lookup field to a list using the Field Element

Configuration, Developers, SharePoint 2010, Uncategorized No Comments »

SharePoint 2010 offers a lot of new functionality for listings. One of them is “Additional Columns”. So what does it mean? Let’s say we have two lists called Provinces and Cities. Each City is in one of the Provinces.

This means that you create a lookup field from the Cities list to the Provinces list.  But i want to see the title and the province code of the Province. This is established using so called additional columns.

additionalcolumns1

Goto the list settings of the Cities list and add a new column. Call that column Province and set the type to Lookup. Now you will get options for additional columns. Select the Provinces list from the dropdown box and choose the field Title as value for that column. Now indicate the ProvinceCode field as an additional column.

additionalcolumns2

When returned to the list settings you will notice that a lookup field is created called Province and a lookup field called Province:ProvinceCode. That last field is the additional column. When a province is selected for a city the additional field from the refered province item is shown in the city item.

When you create a solution for a customer you will be creating definitions of Fields, ContentTypes and Lists. To create a lookup field and an additional column is as follow:

  <Field ID=”{2E652DA6-D53B-4C5F-8C98-1ADCB98F1E71}”
   Name=”Province”
   DisplayName=”Province”
   Type=”Lookup
   FieldRef =”ID”
   ShowField =”Title
   Required=”TRUE”
   Group=”MyFields”
   List=”Lists/Provincies“>
  </Field>

  <Field ID=”{55b4c728-dc8c-4255-bcee-9ffa6ee24020}”
  Type=”Lookup”
  DisplayName=”Province:ProvinceCode”
  List=”Lists/Provincies
  ShowField=”ProvinceCode”
  FieldRef=”{2e652da6-d53b-4c5f-8c98-1adcb98f1e71}
  ReadOnly=”TRUE
  Name=”Province_x003a_ProvinceCode“>
  </Field>

You will notice a few things:

a) The Field Province is needed before the additional field is created. The additional field refers to the Field Province by the FieldRef property.
b) The List property of both Field elements referes to the Provinces list.
c) The Name property contains the value Provincie_x003a_ProvinceCode which is actually the Name of the Field Province, the “:” character translated to _x003a_ and the name of the field ProvinceCode which is refered by the additional column.
d) The ReadOnly attribute fo the additional column is set to TRUE. You are not able to change additional columns. They are only retrieved as extra data from the refered list.

Add both Field elements as a FieldRef to your ContentType and schema.xml file of the list.

Because the Province:ProvinceCode column is now part of the Cities list you are able to query it by for example CAML code. 

SPList list = site.RootWeb.Lists["Cities"];
SPQuery query = new SPQuery();

query.Query = string.Format(@”
                                <Where>
                                    <Eq>
                                        <FieldRef Name=’Provincie_x003a_SVnProvinceCode‘ />
                                               <Value Type=’Lookup’>{0}</Value>
                                    </Eq>
                                </Where>”,
                               4);

 SPListItemCollection cityCollection = list.GetItems(query);

In stead of getting the cities based on the title of the province, you have the ability to do it based on the province code.

SetAvailablePageLayouts generates “Failed to compare two elements in the array”

C#, Developers, SharePoint, SharePoint 2010, Software Development No Comments »

SharePoint offers a great method on the PublishingWeb object called SetAvailablePageLayouts. With this method you are able to set the list of page layouts available to the users of your SharePoint website. Mostly we use this method inside the FeatureActivated method of an SPFeatureReceiver derived class. The code is as follow:

System.Collections.Generic.List<PageLayout> allowedPageLayouts = new System.Collections.Generic.List<PageLayout>();
allowedPageLayouts.Add(publishingSite.PageLayouts["/_catalogs/masterpage/Home.aspx"]);
allowedPageLayouts.Add(publishingSite.PageLayouts["/_catalogs/masterpage/Article.aspx"]);
allowedPageLayouts.Add(publishingSite.PageLayouts["/_catalogs/masterpage/News.aspx"]);
allowedPageLayouts.Add(publishingSite.PageLayouts["/_catalogs/masterpage/FAQ.aspx"]);
publishingWeb.SetAvailablePageLayouts(allowedPageLayouts.ToArray(), true);

Last week i did implemented this again for a project and it causes a nasty error “Failed to compare two elements in the array”. Looking on the internet was not really helpfull till somebody pointed me out that it could be caused by an invalid page i was trying to set as available. The strange thing was that i tested all page templates and could not find any mistake.

After some time i suddenly saw the problem. The page templates where added using a feature. In the elements.xml file each page template was defined by a <Module />, <File /> and <Property /> elements. One of the properties refers to a Content Type by its name and its Id. It seems that i forgot an# sign  in the PublishingAssociatedContentType element.

<File Path="News.aspx" Url="News.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="$Resources:mysolution,PageLayout_News_Title" />
<Property Name="MasterPageDescription" Value="$Resources:mysolution,PageLayout_News_Description;" />
<Property Name="ContentType" Value="$Resources:mysolution,ContentType_News_DisplayName" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/News.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/News.png" />
<Property Name="PublishingAssociatedContentType" Value=";#$Resources:svn,ContentType_SVnNews_Name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0041b83af6a3dd4e90a5e3552f14065687008437ce3f2cca491eadb900969009f447;#"/> </File>

It still added the page template and looking closer to the template list you could see that it wasn’t attached to its Content Type. Hopefully this post will help you when you encounter the same error in your solution.

Error occurred in deployment step ‘Recycle IIS Application Pool’

Developers, SharePoint, SharePoint 2010 No Comments »

Currently i’m working on a development machine for SharePoint 2010. Even the development machine is setup with multiple accounts as security describes. Therefore sometimes you run into strange (security) error messages. The following error message occured when i tried to deploy a SharePoint project from Visual Studio 2010.

Error occurred in deployment step ‘Recycle IIS Application Pool’: <nativehr>0×80070005</nativehr><nativestack></nativestack>Access denied

It seems that the account under which your Visual Studio 2010 is running needs to have sufficient rights on the web application to which you are deploying your solution. In my case this was easily fixed by putting my domain account in the site collection administrators list for that specific web application.

Microsoft SharePoint 2010 Software Development Kit Available

Developers, SDK, SharePoint 2010, Software Development No Comments »

The Microsoft SharePoint 2010 Software Development Kit is available for download. It contains conceptual overviews, programming tasks, samples, and references to guide you in developing solutions based on SharePoint 2010 products and technologies.

As stated on the website “The Microsoft SharePoint 2010 Software Development Kit (SDK) includes documentation and code samples for Microsoft SharePoint Foundation 2010 and for Microsoft SharePoint Server 2010, which builds upon the SharePoint Foundation 2010 infrastructure. The documentation includes detailed descriptions of the technologies that SharePoint Server 2010 and SharePoint Foundation 2010 provide for developers, reference documentation for the server and client object models, and step-by-step procedures for using these technologies and object models and programming with them. This SDK also includes best practices and setup guidance to help you get started with your own custom applications that build and extend upon the SharePoint Foundation 2010 and SharePoint Server 2010 platforms.

Download the SharePoint 2010 Software Development Kit here.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in