Filter on current user with CAML Query.


Hi everybody,

Today I will give you a little trick with CAML Query: how to retrieve the current user.

Logic suggests that we write a query like this:

 <Eq> <FieldRef Name='AssignedTo' /> <value Type='User'> [Me]</ Value> </ Eq>  

But then, it does not work …
The proper way to retrieve the current user is to change our query like this.

 <Eq><FieldRef Name='AssignedTo' /><Value Type='Integer'><UserID Type='Integer'/></Value></Eq> 


And that way we get the current user.

Christopher.

Developpements Sample


Hello,
A short post to talk about an interesting information found on the Renaud Comte’s blog.
Here is a link to download sample of SharePoint 2010 development

http://code.msdn.microsoft.com/SharePoint-2010-101-Code-da251182

I’ve search a little more and found another link with .Net 4.0 sample (which can be also useful)

http://code.msdn.microsoft.com/Visual-Studio-2010-Samples-31b491f3

Happy coding !

Christopher.

List Url to avoid


Hello everybody,

For once I’m not going to talk about development, but just using SharePoint. Specifically the Manage content and structure that is accessible via the button of the same name or when you want to add a link to a document from SharePoint.

All or almost all of us already have experienced a nice error message when trying to access to the Manage content and structure, for example if you have a list instantiated on a template but the template has been modified/removed so that the list is no longer valid.

But no development here now, just a standard site with features of active publications and a custom list named “index_file”, nothing too serious.

Imagine my surprise when browsing the above menu to see the famous explicit error message from SharePoint: An unexpected error has occurred.

After some investigation I discovered the following: When a list has it’s url ending with “_file” or “_files”, it caused an error when you try to access the Manage the content and structure

 

Christopher.

Windows Application : SPSite FileNotFound


I was creating a Windows application to attack my site SharePoint 2010 when I came across a strange problem. My first test was to try to display the name of my site in my Windows Form.

A simple code that runs by clicking the button:

 
private void btnGO_Click(object sender, EventArgs e) 
{ 
     using (SPSite site = new SPSite(tbUrl.Text)) 
      {   
          using (SPWeb web = site.OpenWeb(site.RootWeb.ID)) 
            { 
               lblResult.Text = "Titre du site web = "+web.Title;
            } 
      } 
} 

Nothing is more basic, but I was surprised to see the following error appears:

FileNotFound on a new SPSite when I was just surfing on it.

Being accustomed to the oddity of SharePoint I did several tests, I used “localhost: 5555” instead of the address of my server, hardcoded the link into the code, nothing to do, always wrong.

After cursing SharePoint 2010 for 10 minutes (since this code works perfectly in 2007, I admit I was a little frustrated) I browsed in the project properties and came across the next section.

And then the penny dropped, SharePoint 2010 is 64 bit … After changing it, I renewed my attempt and it wor … no, it did not work. But at least the error was different.

A small compatibility issue between SharePoint and . Net 4.0 . So I went back in to change the properties Framework to target and the 3.5

Rebuild , and then retry and it worked !

In summary, if Visual Studio 2010 is very user friendly for SharePoint component developments, yet he does not do ALL work and some settings are still to be done manually for developments “exotic”.

Hope this helps.

Christopher.

Upload Multiple Document control disabled


By development I came across another oddity of SharePoint (and yes again ^ ^).

Wanting to upload multiple files by hand in the style library I realized that this was not possible

So I stop you there already, yes you there in the background that will say “yes but you are using Chrome, compatibility with SharePoint is not complete, etc.. ”

Never mind, I try via IE (64bit IE9 to be precise) and therefore

And yes … same thing …

Not losing patience (or just a little …) I thought I would try the 32 bit version of IE (since itis installed even though I confess I do not understand why IE has fun have different versions, that anyway SharePoint 2010 uses the 64bit as my Windows Seven is but try)

Oh hey, it works!

Well I’ll restrain myself from commenting on the easy logic of IE developers and just hope it will help someone.

Christopher.