Group & Sort by Month in List View Trick

Group by month is very simple task to achieve in SharePoint List View.
Simply create one computed column with formula:

=TEXT([Start Time],"mmmm")

Now Group by that view by this field to view in particular order ascending or descending.

SiteColumnView
As shown above, it will only order item by alphabetically for month keyword, but it will not order as per the month ordering.

So to achieve that add following formula:
=REPT(" ",13-MONTH([Start Time]))&TEXT([Start Time],"mmmm")

SortByMonth

What’s the trick? To force the order, we are adding a bunch of white spaces before the month name. The calculated Month actually contains the following values (each _ represents a white space):
____________January
___________February
__________March

__November
_December

Now, why don’t we see these spaces on the Web page? What makes the magic work is that when you insert multiple spaces in a Web page, the html specification says that

user agents should collapse input white space sequences

That’s it!

Set an Email alert for Document library or List for SharePoint 2013

In this post, I will explain how to add an alert on document library or list to get notified about item added, updated or deleted. Steps to follow for adding an alert:

1. First of all Open List or Library.
2. If it is library then open Documents, or it is List then open Lists ribbon tab. In my example I have taken Document Library.

LibraryTab
3. Now under Share & Track section, search Alert Me option. Click on Set alert on this library

Set Alert Link

4. A dialog box will appear with available options like Alert Title, Send Alerts To, Delivery Method, Change Type, Send Alerts for These Changes, When to Send Alerts.

Alert Dialog Options

5. Apply relevant configuration on dialog and then click OK. And you are done with setting alert.

How to refresh List View in SharePoint 2013 using JavaScript

One of the short tip to refresh the list view using JavaScript code is as below:

// Set Ajax refresh context
var evtAjax = {
  currentCtx: ctx,
  csrAjaxRefresh: true
};
// Initiate Ajax Refresh on the list
AJAXRefreshView(evtAjax, SP.UI.DialogResult.OK);

You can place this code after completing your operation on list item or on success method. Where ctx is the current site context.

var ctx = SP.ClientContext.get_current();

This code usually helps in Client Side Rendering (CSR) / JSLink.

Keep SharePointing!

Add Navigate up with SharePoint 2013 Design Manager in custom master page

In SharePoint 2013, there is hidden code to have navigate up option. To bring back that functionality in our custom master page, we can put following snippet inside HTML master page (.html file). This snippet is copied from seattle.html (HTML master page file).

<div class="ms-breadcrumb-dropdownBox">
  <!--SPM:<SharePoint:AjaxDelta id="DeltaBreadcrumbDropdown" 
            runat="server">-->
    <!--SPM:<SharePoint:PopoutMenu
            Visible="true" runat="server"
            ID="GlobalBreadCrumbNavPopout"
            IconUrl="/_layouts/15/images/spcommon.png?rev=23"
            IconAlt="<%$Resources:wss,master_breadcrumbIconAlt%>"
            ThemeKey="v15breadcrumb"
            IconOffsetX="215" IconOffsetY="120"
            IconHeight="16" IconWidth="16"
            AnchorCss="ms-breadcrumb-anchor"
            AnchorOpenCss="ms-breadcrumb-anchor-open"
            MenuCss="ms-breadcrumb-menu ms-noList">-->
       <div class="ms-breadcrumb-top">
         <!--SPM:<asp:Label runat="server" 
                  CssClass="ms-breadcrumb-header"
                  Text="<%$Resources:wss,master_breadcrumbHeader%>"/>-->
       </div>
       <!--SPM:<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb"
          runat="server">-->
         <!--SPM:<SharePoint:ListSiteMapPath
              runat="server" PathSeparator=""
              SiteMapProviders="SPSiteMapProvider,SPContentMapProvider"
              RenderCurrentNodeAsLink="false"
              CssClass="ms-breadcrumb"
              NodeStyle-CssClass="ms-breadcrumbNode"
              CurrentNodeStyle-CssClass="ms-breadcrumbCurrentNode"
              RootNodeStyle-CssClass="ms-breadcrumbRootNode"
              NodeImageOffsetX="0" NodeImageOffsetY="289"
              NodeImageWidth="16" NodeImageHeight="16"
              NodeImageUrl="/_layouts/15/images/fgimg.png?rev=23"
              RTLNodeImageOffsetX="0" RTLNodeImageOffsetY="312"
              RTLNodeImageWidth="16" RTLNodeImageHeight="16"
              RTLNodeImageUrl="/_layouts/15/images/fgimg.png?rev=23"
              HideInteriorRootNodes="true" SkipLinkText=""/>-->
       <!--SPM:</asp:ContentPlaceHolder>-->
    <!--SPM:</SharePoint:PopoutMenu>-->
   <!--SPM:</SharePoint:AjaxDelta>-->
</div>

This code blocks will bring back the navigate up menu fly out options, see screenshot below:

Navigate Up SharePoint 2013

This is the simple way to have navigate up option using HTML master page in Design Manager.

If you have not used design manager and you want this navigate up feature, in that case simply place below snippet in your Master page (.master file):

<div class="ms-breadcrumb-dropdownBox" style="display:inline-block;">
  <SharePoint:AjaxDelta id="DeltaBreadcrumbDropdown" runat="server">
    <SharePoint:PopoutMenu runat="server" ID="GlobalBreadCrumbNavPopout"         IconUrl="/_layouts/15/images/spcommon.png?rev=23"         IconAlt="&lt;%$Resources:wss,master_breadcrumbIconAlt%&gt;"         ThemeKey="v15breadcrumb" IconOffsetX="215" 
        IconOffsetY="120" IconWidth="16"
        IconHeight="16" AnchorCss="ms-breadcrumb-anchor"
        AnchorOpenCss="ms-breadcrumb-anchor-open" 
        MenuCss="ms-breadcrumb-menu ms-noList">
        <div class="ms-breadcrumb-top">
          <asp:Label runat="server" CssClass="ms-breadcrumb-header"
            Text="&lt;%$Resources:wss,master_breadcrumbHeader%&gt;" />
        </div>
    <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" 
     runat="server">
      <SharePoint:ListSiteMapPath runat="server"
        SiteMapProviders="SPSiteMapProvider,SPContentMapProvider"
        RenderCurrentNodeAsLink="false" PathSeparator=""
        CssClass="ms-breadcrumb" 
        NodeStyle-CssClass="ms-breadcrumbNode"
        CurrentNodeStyle-CssClass="ms-breadcrumbCurrentNode"
        RootNodeStyle-CssClass="ms-breadcrumbRootNode" 
        NodeImageOffsetX="0" NodeImageOffsetY="289" 
        NodeImageWidth="16" NodeImageHeight="16"
        NodeImageUrl="/_layouts/15/images/fgimg.png?rev=23"
        RTLNodeImageOffsetX="0" RTLNodeImageOffsetY="312"
        RTLNodeImageWidth="16" RTLNodeImageHeight="16"
        RTLNodeImageUrl="/_layouts/15/images/fgimg.png?rev=23" 
        HideInteriorRootNodes="true" SkipLinkText="" />
      </asp:ContentPlaceHolder>
    </SharePoint:PopoutMenu>
  </SharePoint:AjaxDelta>
</div>

Note: Into this snippet, you can place your own image as node image or Popout image.

Hope this helps!

Cheers!

How to verify if the Page is in Edit mode using JavaScript in SharePoint 2013

Hi Guyz,

In one of my project there was need to have a specific edit mode functionality to be implemented, so there might be lot of approaches we can have but I found some of the below approaches that we can implement to verify if the page is in edit mode using JavaScript.

For Publishing Page
SharePoint default input called MSOLayout_InDesignMode is there. If the value is 1 then page is in edit mode else it is in display mode.

var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;

if (inDesignMode == "1")
{
   // page is in edit mode
}
else
{
   // page is in browse mode
}

This will refer to value of the following html input control, which is rendering on the page when it is in edit mode:

<input id="MSOLayout_InDesignMode" name="MSOLayout_InDesignMode" type="hidden" value="1" />

For Wiki Pages
Same as above another default input _wikiPageMode parameter will be used. If the value is Edit page is in edit mode else in display mode.

var wikiInEditMode = document.forms[MSOWebPartPageFormName]._wikiPageMode.value;
if (wikiInEditMode == "Edit")
{
   // wiki page is in edit mode
}
else
{
   // wiki page is not in edit mode
}

Custom Code Snippets
Also you can place some snippet control to master page or page layout if you have customized it and place following snippets:

<PublishingWebControls:EditModePanel ID="EditModelPanel1" runat="server" PageDisplayMode="Edit">
    <h1>You are in EDIT mode</h1>
    <!-- Place you're javascript for execute only in edit mode -->
</PublishingWebControls:EditModePanel>

<PublishingWebControls:EditModePanel ID="EditModelPanel2" runat="server" PageDisplayMode="Display">
    <h1>You are in DISPLAY mode</h1>
    <!-- Place you're javascript for execute only in display mode -->
</PublishingWebControls:EditModePanel>

Cheers!

Enable “Sign In As Different User” in SharePoint 2013

In SharePoint 2010, there was a option available for signing as a different user. But in SharePoint 2013, that option has been removed.

Without Sign In option

I don’t know why Microsoft has removed this precious feature, but there are some workarounds to get back that feature.


Workaround 1:

  • Start Internet Explorer by using the Run as different user option, and then go to the SharePoint site.
    Note: The Run as different user option is visible if you hold the Shift key when you right-click a program icon.
  • Access the SharePoint site by using the the URL as http://siteurl/_layouts/15/closeConnection.aspx?loginasanotheruser=true
    Important: This option uses an unsupported browser feature which is unreliable and causes other issues. Currently this option does not work in IE 10 and Safari.

Workaround 2:

  • Go to the location C:\Program Files\Common Files\microsoft shared\Web ServerExtensions\15\TEMPLATE\CONTROLTEMPLATES
    There will be file called Welcome.ascx
    WelcomeEdit
  • Open welcome.ascx in Visual Studio or in Notepad and add the following code and save.<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />Edit Welcome.ascx
  • Once you save this file, the feature will be enabled.
    With Link

Very simple workarounds to get back this feature.

Cheers!

Powershell List Operations

Various Powershell List Operations of SharePoint :

#### Create Document Library ####
$spWeb = Get-SPWeb -Identity http://sharepoint/ 
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary 
$spWeb.Lists.Add("My Custom Library","My Custom Library Description",$listTemplate)

#### Add Folder To Library ####
$spDocumentLibrary = $spWeb.GetList("My Custom Library")
$spFolder = $spDocumentLibrary.AddItem("",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,"My New Folder")
$spFolder.Update()

#### Allow adding Content type to Library - Enable Content Type ####
$spDocumentLibrary.ContentTypesEnabled = $true

#### Add New Content Type to Library ####
$newCTtoAdd1 = $spWeb.ContentTypes["Content Type Name"]
$newCT1 = $spDocumentLibrary.ContentTypes.Add($newCTtoAdd1)

#### Remove Content Type from Library ####
$oldCTtoRemove = $spDocumentLibrary.ContentTypes["Document"]
$spDocumentLibrary.ContentTypes.Delete($oldCTtoRemove.Id)
$spDocumentLibrary.Update()