Feeds:
Posts
Comments

Introduction

When in a (localized) variations site, certain “list templates” do not show when trying to create a new list. The “list template” is only available in the master variation with the locale set to English.

Including list templates in your SharePoint (Visual Studio) projects can be straight forward. On a list do a “save as template”, download the ‘stp’ file and add it to your project. However they need to be localized to show in a localized (variations) site.

For information about localization see here : http://msdn.microsoft.com/en-us/goglobal/bb688174

The Solution

To localize the stp files :

  • Download the list template to your local computer.
  • Change the extension of the file from ‘stp’ to ‘cab’.
  • Open the cab file with your compression tool of choice (I use WinRar)
  • Extract the manifest.xml to your hard drive.
  • Open the manifest.xml with Notepad
  • You will notice that there is a <language> tag is defined.
    In my sample this is:
    <Language>1033</Language>
  • Simply change the number between the language tags to the desired ‘locale’.
    Examples:
    Dutch is number 1043
    French is number 1036.

    For a full list of the defined locale numbers look here:
    http://msdn.microsoft.com/en-us/goglobal/bb964664

  • Save the manifest.xml
  • Create new stp file

  • Now we will recreate the cab file with CABARC. See details below.
  • Open the command prompt and type the following command:
    CABARC.EXE N “CarouselTemplateNL.cab” C:\Temp\Project1\CarouselTemplateNL\*.*

  • This will result in a new cab file called: “CarouselTemplateNL.cab”
  • Rename the file back to .stp
  • Upload the file into your list templates gallery
    Site Actions -> Site settings -> Galleries -> List templates -> Upload document

CABARC

“CABARC” is a program from Microsoft to create cab files. Lately it has been replaced by a new program called “makecab”.

CABARC did the job for me but you probably can achieve the same result with makecab

You can download CABARC by downloading the Windows XP Service Pack 2 Support Tools
http://www.microsoft.com/download/en/details.aspx?id=18546
There is no need to install this package. Just unzip the file (and it’s cab files) to your locale machine. One of the unzipped files is CABARC.

Tip for when you don’t know what locales are installed on your SharePoint server.
The quickest way is go to the SharePoint installation folder (aka ’14 hive’) and look in the /TEMPLATE/LAYOUTS folder.

When creating event receivers or workflows it might be interesting to look at the differences between the following SPListItem methods. The differences might be subtle but it can make a huge difference when you have extra event receivers or workflows attached to your SharePoint list or items.

Update()

  • Updates the item in the database.
  • Updates the “Modified” and “Modified by” values.
  • Creates a new version

Systemupdate()

  • Updates the item in the database.
  • No changes in the “Modified” and “Modified By” fields.
  • No new version.
  • Triggers the item events.

Systemupdate(true)

  • Same as Systemupdate() and increments the item version.
  • Using SystemUpdate(false) is exactly the same as SystemUpdate()

UpdateOverwriteVersion()

  • Updates the item but does not create a new version.
  • Updates the “Modified” and “Modified by” values.

Note that :
You can also disable the triggering of events by using “this.EventFiringEnabled = false;”. Do your update and enable the events again with “this.EventFiringEnabled = true;”

Hope it helps,
W0ut

Quick description

Application Tool Manager (APM) is a great utility when programming for SharePoint 2010 (and general (IIS) web development) . Very handy if you want to attach your debugger to a specific w3wp.exe Process ID (PID)

The description on their website

This freeware application is a System Tray utility for providing quick access to common IIS tasks which are useful on a SharePoint development box. It may also be useful to others working with IIS. In essence, it enumerates the app pools on your box and lets you right click ‘em to bounce ‘em!

You can download the tool here<: http://www.harbar.net/articles/apm.aspx

 

We often get Excel files with content to import into SharePoint. Most of the time I fire up Visual Studio and write a small console application to import the Excel data. However with SharePoint 2010 I got the error “The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine”.

The idea

When I need to import content into SharePoint using the oledb data is far the easiest way to read Excel files without having to install office on your SharePoint server.

You simply add an OleDbConnection , an OleDbCommand, an OleDbDataAdapter and a correctly formulated select statement.

            string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Import\Sample.xslx; Extended Properties=""Excel 8.0;HDR=Yes"";";
            string CommandText = "SELECT * FROM [Services$]";

            OleDbConnection connection = new OleDbConnection(ConnectionString);
            OleDbCommand command = new OleDbCommand(CommandText, connection);
            connection.Open();

            OleDbDataAdapter adapter = new OleDbDataAdapter(command);

            DataSet dataset = new DataSet();
            adapter.Fill(dataset, "Excel");

The cause

SharePoint 2010 is 64 bit so you need to compile your custom SharePoint code as a 64-bit applications. However the default Jet Library does not support 64-bit applications and thus results in the following error:

The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine.

Solution

Luckily Micosoft has released a solution in the form of the Microsoft Access Database Engine 2010 Redistributable

  1. Download the Microsoft Access Database Engine 2010 Redistributable
  2. Install the package on your development machine
  3. Modify your OleDb Connection string from:
    Provider=Microsoft.Jet.OLEDB.4.0; ….
    to
    Provider=Microsoft.ACE.OLEDB.12.0;….
  4. rebuild your application
    note
    : make sure your application is set to compile as a 64 bit application

Don’t forget to install this redistibutable on your SharePoint server as well.

Here is a NLog config file that generates a similar log file layout as with the (default) Log4Net settings.

This NLog configuration also includes the date in the log file name to mimic the Log4Net ‘rollingFileAppender’ behavior.

file: NLog.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true">

  <targets>
    <target name="logfile" xsi:type="File" fileName="C:\Projects\logs\MainLog.${shortdate}.log" layout="${level:padding=-6}  ${threadid:padding=-4} ${processid}   ${longdate}  ${logger:shortName=true:padding=-24} ${message} ${exception:format=ToString,StackTrace}"/>
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="logfile" />
  </rules>

</nlog>

When using a custom master page and editing a page in SharePoint 2010 I received a dialog box the following error:

“You must specify a value for this required field”.

This error is caused when you set the contentplaceholder ‘PlaceHolderPageTitleInTitleArea’ to: Visible=”False”. After removing the Visible=False attribute from the contentplaceholder the error disappeared.

As a workaround you can wrap the contentplaceholder in a <div> and hide the div with a little CSS. That way the contentplaceholder is still in place but hidden for the user.

<div style="display: none;">
    <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" >&nbsp;</asp:ContentPlaceHolder>
</div>

Hope it helps.

Format xslt date

To format data in SharePoint I often use xslt. The default formatting of dates however is pretty useless

<xsl:value-of select="@YourDateParam"/>

Results in : 2009-03-23 00:00:00

 

You can also use a predefined locale like this:

<xsl:value-of select="ddwrt:FormatDate(@YourDateParam, 1033, 15)"/>

Results in : Thursay, August 24, 2011 09:00:00 PM

 

If your required date time format is not available, you can also define a custom date time formatting.

<xsl:value-of select="ddwrt:FormatDateTime(string(@YourDateParam) ,1033 ,'dd-MMM-yyyy')" />

Results in : 22-03-2011

<xsl:value-of select="ddwrt:FormatDateTime(string(@YourDateParam) ,1033 ,'dd/MMM/yyyy')" />

Results in: 22/Sep/2011

Other formats

Output Locale Format
3/23/2009 1033 1
3/23/2009 12:00 AM 1033 2
Monday, March 23 2009 1033 3
12:00 AM 1033 4
Monday, March 23, 2009 12:00 AM 1033 7
3/23/2009 12:00:00 AM 1033 13
Monday, March 23, 2009 12:00:00 AM 1033 15
23/03/2009 2057 1
3/23/2009 12:00 AM 2057 2
23 March 2009 2057 3
00:00 2057 4
23/03/2009 00:00 2057 5
23 March 2009 00:00 2057 7
00:00:00 2057 12
23/03/2009 00:00:00 2057 13
23 March 2009 00:00:00 2057 15

Christophe Geers has a great article about how to setup a build server with Jetbrains TeamCity.

Read his article here:
http://cgeers.com/2011/05/28/running-unit-tests-with-teamcity/

I ‘m planning on integrating a build server in my Media Center. I was still reading up on all the different products and technologies available. After reading Christophe’s article I might go for the TeamCity as well.

Regards,

Good news!! JetBrains released the first version of their free decompiler tool, dotPeek.

Since the February 2011 the .NET community was looking forward for a new free decompiler tool after RedGate announced that their insanly popular decompiler tool ‘Reflector’ would no longer be free. Jetbrains reacted and is giving the .Net community: dotPeek.

DotPeek was already available with Resharper (beta) builds but now it’s also available as a standalone version!

Download the goodness here:
http://blogs.jetbrains.com/dotnet/2011/05/free-net-decompiler-is-available-for-early-access/

It’s free and supports .Net assemblies from version 1.0 to 4.0.

I’m a long time fan of JetBrains Resharper product. If the quality of dotPeek is equally good then RedGate Reflector will soon be forgotten. ;-)

Keep up the good work!!

Regards, W0ut

Introduction.

In SharePoint 2010 you can use Google Maps without having to download extra webparts or third party tools. In this article I will explain how you can insert “Google Maps” maps in your SharePoint 2011 site with only using standard out of the box SharePoint 2010 features.

It’s a generic solution which can also be used to store HTML code that defines Flash and Silverlight HTML ‘assets’.

1. Get your Google map code.

  • Go to Google maps
  • Find the location you want.
  • In the right hand corner of the map click on “Link”
  • Next click on “Customize and preview embedded map”.
  • Enter the desired options.
  • Copy the HTML code that Google generates for you.
  • Paste the HTML code in a text file (use notepad).
  • Save the text file to your hard drive.

So you have the Google Map HTML code sitting in a text file now. Next step is to upload this file in SharePoint

2. Store the HTML code in SharePoint.

  • Go to your SharePoint site.
  • Click on ‘Site Actions’ =>’More Options’.
  • Click create and create a new Document Library “
  • When the library is created. Click on “Add document”.
  • And upload the Google Map text file you created in the previous step

Your Google Maps HTML code is in SharePoint now.  Next step: display it.

Note 1: An asset might be a more appropiate naming.  So an “Asset Library” might be a better choice. For simplicity sake we stick with a standard “Document Library”
Note 2: Feel free to add your custom content types to the library and fill out out the required meta data.

3. Display the Google Map.

Get the document url :

  • Go the library from the previous step.
  • Click on the Google Maps document you want to display.
  • SharePoint opens this file as plain text in your browser.
  • Copy the url of this file from your browsers address bar.

Add the Google Map to a page :

  • Open the a SharePoint page.
  • Edit the page.
  • Add the Content Editor web part
  • Clicking on “Edit Web part” in the web part context menu
  • Insert the document url, of the Google Maps text document, in the “Content Link” box.
  • Click on OK
  • Save the page.
  • If needed check-in and approve the page.

That’s it. Your Google Map is now visible on the SharePoint site.

The nice thing is that you can reuse this map in your SharePoint site. And when the map changes (change of address, etc…) you only need to change the text file in your Document Library.

Regards,
W0ut

Older Posts »

Follow

Get every new post delivered to your Inbox.