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
Follow

Get every new post delivered to your Inbox.