Multilingual Settings in SharePoint 2010

March 17, 2011 3 comments

A quick blog post on how to enable (and how to select) multilingual settings on a SharePoint 2010 site.
Go to Site Actions, Site Settings
image
Select Language Settings under Site Administration
image

 

In the settings, select the languages that you would like to add (I only installed the Dutch Language Pack)

image
Leave the Overwrite Translations as it is for now, I’ll get back to that in a sec. Now go back to your original site. On the top right, select your Username. There you should now be able to select in which language you would like to see the site:

image

 

Leave it at English for now. Open the document library Shared Documents and add a column named MySpecialColumn, type text.

image

There we go, now change the site to Dutch (or whatever language pack you have installed). You should now see that the column names are being translated, but your new column’s name is not being translated.
Go back to the Document Library settings and change the name of the column to the translated name.

image

If you now switch to English you will see that the column is called MySpecialColumn, while in the Dutch site it will be called MijnSpecialeKolom. This enables the users to do the translations themselves. It would have been nice if in the interface, when we added a column that we could enter all the translations at creation, but it’s another step in the good direction 🙂 More on the multilingual aspect soon!

Categories: Uncategorized

Exception: System.SystemException: The trust relationship between this workstation and the primary domain failed.

March 17, 2011 Leave a comment

As I installed the language packs for SharePoint 2010 I ran into the Exception: Exception: System.SystemException: The trust relationship between this workstation and the primary domain failed.

The cause of this error, in my case, was that the SharePoint 2010 server was unable to contact the Domain Controller. Once that was sorted, I could run the configuration wizard just fine.

Categories: Uncategorized Tags: , , ,

HOWTO: Create a List and bind a Content Type to it in SharePoint 2010

April 28, 2010 1 comment

In the following HOWTO I will explain how you can create a list declaratively on a SharePoint site by making use of the Visual Studio 2010 Tools. In that list we will give automatically add the hotel conten type to the list so that the user can only add “hotels” to that list. If you do not know how to create a content type to achieve this, read the following blog post: https://koenvosters.wordpress.com/2010/04/27/howto-build-a-deployable-content-type-for-sharepoint-2010/

We will start from an Empty SharePoint Project. Rightclick the project, select add new item, List Instance.
Add the display name and description and change the list to instantiate to Custom List. If you want a specific url, make sure you specify this in the wizard.
image

This should result in the follwing xml being generated for you:

Code Snippet
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  3.   <ListInstance Title="List of Hotels"
  4.                  OnQuickLaunch="TRUE"
  5.                  TemplateType="100"
  6.                  FeatureId="00bfea71-de22-43b2-a848-c05709900100"
  7.                  Url="Lists/Hotels"
  8.                  Description="List of the Hotels that can be booked by the Travel Agency">
  9.   </ListInstance>
  10. </Elements>

This List Instance will create a list based on the content type item. Once we deploy the solution we will see that a new list has been created called “List of Hotels”. Now we move to the steps to add this content type to a list. First thing to know is that we need to be sure that the list and the content type have already been installed on the server. How do we do that? We will create a new feature in our project and that Feature will have an activation dependency on the feature with the list instance and the content type xaml definition. At that moment the future binding the two together can only be executed when both content types have been created.

image

Add the feature, rename it to something meaningfull like ConnectingListCtypes and double click it. In that screen, give it as title Travel Agency. At the bottom of the screen you will see an area called Feature Activation Dependencies. Click on Add on the right side and select the feature with the list instance and the content type in it. Then click Add.

image

As we have two features it would mean the user would have to click twice to enable our Travel Agency list with content types. To avoid this behavior we will make the feature containing the list instance and the content type hidden. You can do this by going to the properties of the Feature and setting the property Is Hidden to false. That means that whenever I activate my TravelAgent feature it will automatically activate my depencies, invisible to the user.

image

Ok, so now all is linked together, all we need to do is write the actual code that will link the two together. First, we will add a Feature Receiver to the TravelAgent Feature. You can do this by rightclicking the feature and selecting “Add Event Receiver”. Uncomment the code of the FeatureActivated function.

In the code we will create an object for the list called “list” and an object for the contenttype called mytype. We will add this contenttype to the list and remove the existing content type called “Item” which the list was based on. Do not forget to call the update method on the list or the changes will not be submitted.

Code Snippet
  1. public override void FeatureActivated(SPFeatureReceiverProperties properties)
  2.         {
  3.             try
  4.             {
  5.  
  6.                 using (SPWeb web = SPContext.Current.Web)
  7.                 {
  8.                     SPList list = web.Lists["List of Hotels"];
  9.                     SPContentType mytype = web.AvailableContentTypes["Hotel"];
  10.                     list.ContentTypesEnabled = true;
  11.                     list.ContentTypes.Add(mytype);
  12.                     SPContentType itemtype = list.ContentTypes["Item"];
  13.                     list.ContentTypes.Delete(itemtype.Id);
  14.                     list.Update();
  15.  
  16.                 }
  17.  
  18.             }
  19.             catch (Exception ex)
  20.             {
  21.                 TextWriterTraceListener listener = new TextWriterTraceListener("c:\\customcodelogs.txt");
  22.                 listener.WriteLine(ex.StackTrace);
  23.                 listener.Dispose();
  24.             }
  25.         }

As the other feature is hidden you should only see 1 feature to activate in the site settings. Once you activate it, you should have a content type called Hotel in your site collection and a list called “List of Hotels” in your site. Adding an item in your list will present you the new content type. In one of my next posts we will be creating a custom field type so that we can assign “stars” to hotels in an easier way.

Comments are always welcome 🙂

Categories: Uncategorized

SharePoint Saturday in Belgium

April 28, 2010 Leave a comment

On May 8th the first SharePoint Saturday is taking place. Organized by the BIWUG team this event will cover the following topics:

9:30-9:45 Welcome and Introduction

9:45 – 10:30 Visual Studio 2010 Tools for SharePoint (Karine Bosch)

10:40 – 11:30 LINQ to SharePoint (Serge Luca)

11:40 – 12:30 Client Object Model (TBD)

12:30 – 13:40 Lunch break  with sandwiches and drinks

13:40 – 14:30 Sandboxed solutions (Steven Van De Craen) 

14:40 – 15:30 MetaData in SharePoint 2010 (Joris Poelmans)

15:40 – 16:30 SharePoint, WCF Services en REST (Stéphane Eyskens)

 16:30 – Closing drink

Don’t miss it, you can subscribe right here.

 

Categories: Uncategorized

HOWTO: Build a deployable Content Type for SharePoint 2010

April 27, 2010 1 comment

Open Visual Studio 2010, select SharePoint.

Select Empty SharePoint Project.

Right click the project and add a new item
image

Select Content Type, name it Hotel
image

Select Item as Base Content Type

image

This will result in the following xml:

Code Snippet
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  3.   <!– Parent ContentType: Item (0x01) –>
  4.   <ContentType ID="0x01007319db2fac804824ab4fec5c3c2d2208"
  5.                Name="Hotel"
  6.                Group="Travel Agency"
  7.                Description="This Content Type described a hotel that can be booked by the Travel Agency"
  8.                Inherits="TRUE"
  9.                Version="0">
  10.     <FieldRefs>
  11.     </FieldRefs>
  12.   </ContentType>
  13. </Elements>

Note that I already changed the name, group and description to something more meaningful.

A content type is nice, but the real use comes from assigning some fields to it and making it available in a list. (our content type is based on item). The minimal xml for a field in a content type is the following:

  1. <Field ID="{8617CAAA-45D0-4C81-85C9-D1F7BAF99580}" Group ="Travel Agency" Name="StarsHotel" DisplayName="Number of Stars" Type="Number" />

You need to give a field an ID (Guid), a name and a type. For a list of the available types you can check out my blog post on available field types. As we are basing our content type on the item content type, we will already have a title field (which we will be using for the name of the hotel. Let’s add the following properties to our hotel

  • Number of rooms – Number
  • Pool – Yes/No
  • Bar – Yes/No
  • Stars – Number

Once we added all the fields, we will be adding a reference to these fields (who will result in site columns) in our content type with following syntax:

  1. <FieldRef ID="{8617CAAA-45D0-4C81-85C9-D1F7BAF99580}" Name="StarsHotel"/>

If you did all that correctly you should have the following xml.

Code Snippet
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  3.   <!– Parent ContentType: Item (0x01) –>
  4.   <Field ID="{24A3D7D7-EF78-4184-8DA0-E8FC019773AD}" Group ="Travel Agency" Name="Rooms" DisplayName ="Number of Rooms" Type="Number" />
  5.   <Field ID="{E76BCA8A-3385-40E2-AC27-2A04F04F7B49}" Group ="Travel Agency" Name="Pool" DisplayName ="Pool Available" Type="Boolean" />
  6.   <Field ID="{C0890629-8B34-4713-B8C0-61D0D84B6C96}" Group ="Travel Agency" Name="Bar" DisplayName ="Bar Available" Type="Boolean" />
  7.   <Field ID="{8617CAAA-45D0-4C81-85C9-D1F7BAF99580}" Group ="Travel Agency" Name="StarsHotel" DisplayName="Number of Stars" Type="Number" />
  8.   <ContentType ID="0x01007319db2fac804824ab4fec5c3c2d2208"
  9.                Name="Hotel"
  10.                Group="Travel Agency"
  11.                Description="This Content Type described a hotel that can be booked by the Travel Agency"
  12.                Inherits="TRUE"
  13.                Version="0">
  14.     <FieldRefs>
  15.       <FieldRef ID="{24A3D7D7-EF78-4184-8DA0-E8FC019773AD}" Name="Rooms"/>
  16.       <FieldRef ID="{E76BCA8A-3385-40E2-AC27-2A04F04F7B49}" Name="Pool"/>
  17.       <FieldRef ID="{C0890629-8B34-4713-B8C0-61D0D84B6C96}" Name="Bar"/>
  18.       <FieldRef ID="{8617CAAA-45D0-4C81-85C9-D1F7BAF99580}" Name="StarsHotel"/>
  19.     </FieldRefs>
  20.   </ContentType>
  21. </Elements>

Let’s deploy that to our SharePoint Server.

In the site settings of the site collection that we are deploying to, you should see the site columns under Travel Agency and you should see the Content Type under Travel Agency as well. You now succesfully deployed your content type. Once you link it to a list you end up with a hotel content type in your list.

image

In my next blog post I’ll handle linking this content type to a list in your project instead of doing it in the UI.

Categories: Uncategorized

Available Field Types in SharePoint 2010

April 27, 2010 11 comments

This post is a compilation of the fldtypes.xml and the fldtypes_*.xml files in SP2010 that gives a clear overview of the field types we can use. I haven’t added the use of each field yet as I need to test each field to get a good feeling of what it  does.

Out of the box Field Types

Name Use
   
AllDayEvent  
Attachments  
Boolean  
BusinessData  
Calculated  
Choice  
Computed  
ContentTypeId  
Counter  
CrossProjectLink  
Currency  
DateTime  
Decimal  
File  
GridChoice  
Guid  
Integer  
Lookup  
LookupMulti  
ModStat  
MultiChoice  
MultiColumn  
Note  
Number  
PageSeperator  
Recurrence  
Text  
ThreadIndex  
Threading  
Url  
User  
UserMulti  
WorkflowEventType  
WorkflowStatus  

GROUPBOARD Field Types

Name Use
   
CallTo  
Confirmation  
ContactInfo  
Facilities  
FreeBusy  
Overbook  
SendTo  
WhereAbout  

GROUPBOARD Upgrade Field Types (do not use)

Name Use
   
GbwLocation  
GbwParticipants  
GbwSREnd  
GbwSRStart  

Hold Field Types

Name Use
   
HoldsField  
ExemptField  

Publishing Field Types

Name Use
   
HTML  
Image  
Link  
SummaryLinks  
LayoutVariationsField  
ContentTypeIdFieldType  
PublishingScheduleStartDateFieldType  
PublishingScheduleEndDateFieldType  
MediaFieldType  

SPRating Field Types

Name Use
   
AverageRating  
RatingCount  

TargetTo Field Types

Name Use
   
TargetTo  

Taxonomy Field Types

Name Use
TaxonomyFieldType  
TaxonomyFieldTypeMulti  
Categories: Uncategorized

Error occurred in deployment step ‘Recycle IIS Application Pool’: The local SharePoint server is not available.

April 26, 2010 2 comments

I installed the RTM bits of SharePoint 2010 during the weekend. When I was good to go! I started building my first SharePoint Project. Once I tried to deploy, all I got was “Error occurred in deployment step ‘Recycle IIS Application Pool’: The local SharePoint server is not available.”. It took quite a while to figure out what went wrong, and mainly thanks to this blog post I managed to get my stuff working. I personally don’t like to have to change the rights for every content database I create. Therefor, if you do not wish to dive into your SQL every time you want to deploy your solution on a different content database, give your user in SQL Server sysadmin rights. That way it will work for every content database.

NOTE: I got this behavior from installing SharePoint the way you should install it under a different domain account(DOMAINNAME\InstallAccount) and then using “my own account” (DOMAINNAME\Koen) to develop.