Monday, August 19, 2013

How Storage Metrics delivers size of content especially in o365?

SharePoint 2013 introduces Storage Metrics Page for monitoring consumption of storage. This can be used by Site Collection Admins. This is a pretty decent tool especially when it comes to o365.

In SharePoint online, you don't have the ability to use run these commands the Get-SPDatabase or Get-SPContentDatabase as they are not available. You also don't have the ability to access SQL Server to check the size of content database.

Your first choice is to use a tool/webservice to download the entire site collection and then check the size. This is not the best use of any given tool or worth writing a service for.

This is the best way to get the size of the content. Site Settings->Storage Metrics and you could get data like below and using simple Math you could get fairly accurate estimate of the size of content.

% of Parent Size * X = Total Size

75.27/100*X = 181.5

i.e 181.5 * 100/75.27 = (Total Size of Content)











Monday, July 15, 2013

Annoying things of SharePoint Online (Design Limitations)




·         You have no access to ULS Logs. (You would have to work with support and send them the co-relation ID to get back the entry. This does not occur instantly)



·         All emails that coming from SP will come from this email address: no-reply@sharepointonline.com.  You cannot change this!



·         MSFT does not offer premium support for SharePoint Online.

Wednesday, May 15, 2013

Date Conversions/Calculated Fields - SP List

If you need to convert Article Date = '01/01/2013' to 'January 2013, you need to do the following
  • Add a new column to SP List
  • The type of the column is calculated.
  • Insert this formula to get the desired out come. [=TEXT([Article Date],"mmmm")&" "&TEXT([Article Date],"yyyy")]
If you need to convert Article Date = '01/01/2013' to '01 January', you need to do the following:

  • Follow steps 1&2
  • =TEXT(MONTH([Article Date]),"00")&" "&TEXT([Article Date],"mmmm")

Sunday, May 12, 2013

Display Content Editor WebPart only when it contains Content.

  • Define a Page Layout
  • Add a class to the section. - (Example: mainLayout)
  • Add another class to wrap a CE in this section. - (Example: controlContainer)
  • If there is a line break after the page layout, add an id to that control (Example: <BR Id='lineBreak' />
  • Here is the code to add to you .JS file.
        if ($('#mainLayout.controlContainer').length == 0)
        {
            $('#mainLayout').addClass('hidden');
            $('#lineBreak').addClass('hidden');
        };
   
   
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {
            var findEditStyle = "https://SERVER/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#mainLayout').removeClass('hidden');
                    $('#lineBreak').removeClass('hidden');
                };
           
        }

Using Jquery to determine Page in Edit Mode O365

If you have a scenario where you need to determine if the page is edit mode and display a control/container. Here is the approach

  • Define the container with a unique ID/Class
  • Add JQuery to some .js file.
  • Ensure that editmode15.css is loaded in one of the edit panels of the page layout associated with this page. Alternatively, you could also add something else in an edit panel and then check that going through the DOM object.
  • Then, add code like below.
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {

            var findEditStyle = "https://SERVER/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#YourID').removeClass('hidden');
                    $('#YourExtraIDs').removeClass('hidden');
                };
           
        }

Determine if

//Hiding the News From Leaders Section and making it visible in Edit Mode.
        /*
        check to see if WPEditModev4.css is loaded
        if so, this means you're in "edit" mode
        */
        // check to see if no news elements exist in 'News From Our Leaders' section
        if ($('#nLeader .articleContainer').length == 0)
        {
            $('#nLeader').addClass('hidden'); // hide the parent container if no articles
            $('#LeaderBreak').addClass('hidden');
        };
   
   
        loadedStylesheets = document.styleSheets;
   
        for (var i in loadedStylesheets)
        {
            //This path would be fixed as this is being loaded from the page layout.
            var findEditStyle = "https://yumbrandsinc.sharepoint.com/sites/ynn/Style%20Library/en-US/Themable/Core%20Styles/editmode15.css"
            var findStylesheet = "WPEditModev4.css";
                //var currentStylesheet = (loadedStylesheets[i].href.match(/\/([^/]+)$/)[1]);
                if (findEditStyle == loadedStylesheets[i].href)
                {
                    $('#nLeader').removeClass('hidden');
                    $('#LeaderBreak').removeClass('hidden');
                };
           
       

Monday, May 6, 2013

Hide Office365 Logo on SP 2013 sites

Comment the following line in the master page:
                    <!--<SharePoint:DelegateControl id="ID_SuiteBarBrandingDelegate" ControlId="SuiteBarBrandingDelegate" runat="server" />-->

If the above approach does not work, you could use CSS to hide.

Tuesday, April 30, 2013

SP Designer Caching Issues

Issue - If you want to clear up the SharePoint Designer Cache
Resolution - Delete everything from this location %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
SPD 2007, SPD 2010, SPD 2013


Issue - If you want to remove the recent sites when you open SPD.
Resolution - Goto this location %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache and open WebSites.XML file to remove any entry you want.


Note: When you uninstall SPD, this above file is never deleted.
SPD 2007, SPD 2010, SPD 2013

Monday, April 29, 2013

Hide "Share" & "Follow" & "Focus Icon" From Home Page Master Page in SP2013

Comment the following controls on MasterPage..


<!-- Removes Share Button -->
                        <!--<SharePoint:SPSharePromotedActionButton runat="server"/>-->
                        <!--Removes Follow Button-->
                        <!--<SharePoint:DelegateControl runat="server" ControlId="PromotedActions" AllowMultipleControls="true" />-->


<!--<span id="fullscreenmodebox" class="ms-qatbutton">
                    <span id="fullscreenmode">
                        <SharePoint:ThemedClusteredHoverImage
                        runat="server"
                        ID="fullscreenmodeBtn"
                        ThemeKey="spcommon"
                        TouchMode="true"
                        TouchModeWidth="30"
                        TouchModeHeight="30"
                        TouchModePaddingLeft="7"
                        TouchModePaddingTop="7"
                        TouchModePaddingRight="7"
                        TouchModePaddingBottom="7"
                        ImageUrl="/_layouts/15/images/spcommon.png?rev=23"
                        Width="16"
                        Height="16"
                        OffsetX="143"
                        OffsetY="178"
                        HoverOffsetX="125"
                        HoverOffsetY="178"
                        NavigateUrl="#"
                        onclick="SetFullScreenMode(true);PreventDefaultNavigation();return false;"
                        AlternateText="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                        ToolTip="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                        />
                    </span>
                    <span id="exitfullscreenmode" style="display: none;">
                        <SharePoint:ThemedClusteredHoverImage
                            runat="server"
                            ID="exitfullscreenmodeBtn"
                            ThemeKey="spcommon"
                            TouchMode="true"
                            TouchModeWidth="30"
                            TouchModeHeight="30"
                            TouchModePaddingLeft="7"
                            TouchModePaddingTop="7"
                            TouchModePaddingRight="7"
                            TouchModePaddingBottom="7"
                            ImageUrl="/_layouts/15/images/spcommon.png?rev=23"
                            Width="16"
                            Height="16"
                            OffsetX="107"
                            OffsetY="178"
                            HoverOffsetX="179"
                            HoverOffsetY="96"
                            NavigateUrl="#"
                            onclick="SetFullScreenMode(false);PreventDefaultNavigation();return false;"
                            AlternateText="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                            ToolTip="<%$Resources:wss,multipages_fullscreenmodelinkalt_text%>"
                            />
                    </span>
                </span>-->



Tuesday, April 16, 2013

Export/Import TermStore without any code (Exception XSLT) especially for O365

  •     Use Office 2010 client to the output from the web server.
  •     In SP2010, create a new document library.
  •     Add a MM type column.
  •     Open MSFT Word 2010 and save the document lib in the SP lib.
  •     Goto %LOCALAPPDATA%\Microsoft\Office\TermSets and look for GUID.XML file that was recently added. (Note: Ensure you hidden files are viewable)
  •     Select this file and copy it to you folder.
  •     Use XSLT to transfer this content into the Format required to Import CSV.
       
        Here is a document from MSFT, which provides details on the format
        http://technet.microsoft.com/en-us/library/ee424396%28v=office.14%29.aspx   

Wednesday, April 3, 2013

Welcome, First Name Last Name (JQuery Library for SharePoint Web Services)


When a user signs into SP Portal, on the top right hand corner you see name in Format of Last Name, First Name. You could change that by simply using Jquery + SPService (JQuery Library for SharePoint Web Services)

SPService is absolutely phenomenal. It can simply do so much with so little code.

Here is what you need to do to accomplish the desired results.

  • Create a new JS file and link it from your master page.
  • Add a reference to JQuery.SPServices-0.N.N.js to your master page and before your custom .JS File.
  • In the .js file add the following code:

$(document).ready(function() {
    $(".ms-welcomeMenu a.ms-menu-a span").text("Welcome, " + userName);   
        window.userName = "";
   
    var thisUserFirstName = $().SPServices.SPGetCurrentUser({
    fieldName: "FirstName",
    debug: false
    });
   
    var thisUserLastName = $().SPServices.SPGetCurrentUser({
    fieldName: "LastName",
    debug: false
    });

    window.userName = thisUserFirstName + " " + thisUserLastName;
}

Once this code has been put in place, when a user sign in to SP, they will see Welcome, First Name + " " + LastName on the right hand top corner.

Tuesday, April 2, 2013

Render (Published Mode/Edit Mode) OOTB RSS Control

Worked on an OOTB Rss Control web part in O365. It suddenly stopped working on the Home Page. It still works fine on a couple of other pages, but stopped working on the Home Page. The stopped working means that the "loading graphic" stays on Home Page and the RSS Feed never gets rendered. The moment you go into the edit mode, the RSS feed is rendered correctly. This is one of the strangest issues I have seen either this is something related to Office 365?

Here is what I did
  • Master Page is same across the site. Same set of JS/CSS files are loaded on all pages.
  • PageLayout is different. Tried all combinations with using same page layout/rebuilding page layout/ adding components 1 by 1, but still would not work.
  • There are not many configuration settings that you can modify for OOTB RSS Feed.  
Spent lot of hours in order to troubleshoot this crazy issue. Still could not resolve the issue other than this:

Solution:
Used XMLViewer WebPart in place of RSS Control web part and then wrote XSLT used for rendering the content. The 2 things to note here are that
  1. Produce the same look & feel
  2. Limit the Results to a certain number.
This was accomplished, by literally adding the same styles that existed in XSLT/OOTB Control and adding logic to limit to certain number.







Tuesday, March 26, 2013

Change Ratings.png file SPOnline/Office365

There are at least 2 ways available for achieving this:

  1. You could do this in JQuery
  2. You could make a change in SP Designer by making change in the SiteOptions. In the SiteOptions, there is a property Ratings [ratings_imagestripurl], you can update this value. The only catch here is the APP pool has to be restarted.

Change Ratings for Blue to Golden - SP Online Office365

How do you change the ratings from blue to control on the RatingsControl that is rendered.

In SP Online, you have lot of limitations and your best friend is JQuery. There are several ways in which this can be accomplished. A simple way is to swap the class that is used when the ratings control is rendered on the page. Here is how the command will look.

$(".ms-rating_1").addClass("ms-rating_1_new").removeClass("ms-rating_1");

The only issue with this is that there is no matching class when the average rating is 1.5, 2.5...and so forth. In that scenario, you would have to create a new mirror opposite of the rating image and load it to your images folder.




This is an example of that type of code. In this, we would add a class and remove the existing class and then replace the image.

    //$(".ms-rating_4_5").addClass("ms-rating_4_5_new").removeClass("ms-rating_4_5").attr("src", "/sites/ynn/siteAssets/images/Ratings/ratingsEmptyCustom.png")

Alternatively, if you can live without averages rounded to .5 then you can simply do this:

$(".ms-rating_1_5").addClass("ms-rating_2_new").removeClass("ms-rating_1_5");


Wednesday, March 6, 2013

CQWP - Display content from 3rd(N) Position Onwards

Here are the steps:
  • Open ItemStyle.XSLT file
  • Simply create your own template by copying an existing template.
  • Insert the bold variable.
  • Add an "If" condition where the content is rendered.
Using this technique, you can get data from any position onwards.

<xsl:template name="Display2NDRowOnwards" match="Row[@Style='ImageTopCentered']" mode="itemstyle">
        <xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="SafeImageUrl">
            <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
                <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="DisplayTitle">
            <xsl:call-template name="OuterTemplate.GetTitle">
                <xsl:with-param name="Title" select="@Title"/>
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="ItemNumber">
             <xsl:number  format="1"></xsl:number>
        </xsl:variable>

        <div class="item centered4">
            <xsl:if test="string-length($SafeImageUrl) != 0">
                <div class="image-area-top">
                    <a href="{$SafeLinkUrl}" >
                      <xsl:if test="$ItemsHaveStreams = 'True'">
                        <xsl:attribute name="onclick">
                          <xsl:value-of select="@OnClickForWebRendering"/>
                        </xsl:attribute>
                      </xsl:if>
                      <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
                        <xsl:attribute name="onclick">
                          <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
                        </xsl:attribute>
                      </xsl:if>
                      <img class="image" src="{$SafeImageUrl}" title="{@ImageUrlAltText}">
                        <xsl:if test="$ImageWidth != ''">
                          <xsl:attribute name="width">
                            <xsl:value-of select="$ImageWidth" />
                          </xsl:attribute>
                        </xsl:if>
                        <xsl:if test="$ImageHeight != ''">
                          <xsl:attribute name="height">
                            <xsl:value-of select="$ImageHeight" />
                          </xsl:attribute>
                        </xsl:if>
                      </img>
                    </a>
                </div>
            </xsl:if>
            <div class="link-item">
                <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
                <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
                  <xsl:if test="$ItemsHaveStreams = 'True'">
                    <xsl:attribute name="onclick">
                      <xsl:value-of select="@OnClickForWebRendering"/>
                    </xsl:attribute>
                  </xsl:if>
                  <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
                    <xsl:attribute name="onclick">
                      <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
                    </xsl:attribute>
                  </xsl:if>
               
                    <xsl:if test="$ItemNumber > 2">
                          <xsl:value-of select="$ItemNumber" />
                          <xsl:value-of select="$DisplayTitle"/>
                      </xsl:if>


                </a>
                <div class="description">
                    <xsl:value-of select="@Description" />
                </div>
            </div>
        </div>
    </xsl:template>