vendredi 27 décembre 2013

Sharepoint Error: Save Conflict Your changes conflict with those made concurrently by another user

If you develop Sharepoint components that modify list items, you might know this error:
Save Conflict
Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.
This happens whenever you try to save a SPListItem which has been modified since you opened it. Review your code to ensure that you don’t open the same list item multiple times, work with a single SPListItem object instead.
Sometimes however it is necessary to open the same list item in parallel, as example if you want to perform an operation with elevated privileges on the item. If you take this approach you need to ensure that if you save one of the SPListItem objects, you need to reload all other SPListItems that point to the same actual item. Otherwise you’ll get the error above whenever you perform a change on the outdated items.
You can use the following utility method to ease the reloading of items:
/// <summary>
/// Reload a list item from scratch
/// </summary>
/// <param name="item">The list item</param>
/// <remarks>
/// Useful to avoid save conflicts
/// </remarks>
/// <returns></returns>
public static SPListItem ReloadListItem(SPListItem item)
    if (item == null)
        return null;
    return item.ParentList.GetItemByUniqueId(item.UniqueId);

vendredi 13 décembre 2013

SharePoint 2010 / 2013 Get all groups for SPUser including active directory group

SharePoint don't give you groups for SPUser if the right is given by an active directory group.

You have to merge groups specificied directly using user login in sharepoint groups and active directory groups.

private static List<SPGroup> GetAllUserGroups(SPUser user)
    List<SPGroup> groups = new List<SPGroup>();
    //Get groups from SharePoint
    foreach (SPGroup spGroup in user.Groups)
    string userLogin = user.LoginName;

mercredi 10 juillet 2013

SharePoint 2013 , change branding text content


You can easily change the SharePoint branding text that appear in the left corner of you site thanks to this powershell code

PowerShell Snippet

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$webApp = Get-SPWebApplication http://serveurSP
$webApp.SuiteBarBrandingElementHtml = "Larry's Microsoft Technologies Blog"

 Following this example you can also change the background color using CSS :
/* Modification couleur de la barre d'application */
/*Modification de la couleur du texte de la barre d'application */
background-color: rgb(229,226,221);
color: rgb(0,0,0);
This is the final result with suite bar color modification and brand text changing.


lundi 17 juin 2013

See all MSDN articles with Silverlight Pivot Viewer control

Affichage des articles MSDN sous forme d'un contrôle Pivot Viewer

Voici une petite page bien sympathique pour retrouver les articles MSDN, j'attire plus particulièrement votre attention sur la recherche (textbox en haut à gauche) qui est très pratique surtout pour rechercher les commandes powershell.


Package and deploy page layout and master page for SharePoint 2013

There is a lot of new parameters available in the new SharePoint 2013 about page layouts and master page packaging and deployment.

Provision a page layout in sharepoint 2013

A couple of things have changed. The new markup that SharePoint itself uses for provisioning a page layout file looks like this:
Note: you can check this by creating a design package via the new Design Manager, and check the content that has been generated.

Provision a published version 

How to Provision Your Master Pages

For provision master pages, the same approach as discussed above can be used. The only difference will be the properties you're going to provide. The properties that I use in my elements file the following: