Saturday, October 11, 2014

SharePoint 2010 Project Tasks List - Dashboard

It is just a coincident I see a requirement for Project Tasks List dashboard on StackExchange which I recently did for my self.

The overall goal is to show tasks progress in fill bar with overall status. The solution is no server side code solution so it can work in all environment. Following is screenshot how it will look like finally:



Here are step by step guide:

1. Create your Project Tasks list


2. Create a new view

(a) Ensure all required columns are included




(b)Ensure all items return in one set and not in batch.





3. Upload XSL file to a document library.

4. Add List WebPart to page



5. Edit List WebPart
(a) Select View that we created


(b) Put XSL file path that has been uploaded to document library



Now you should see similar like this:





Saturday, July 26, 2014

How To Figure Out SharePoint List or Document Library Column's Internal Name

SharePoint List and Document Library has a fixed internal name beside title of that field shown to user.
This field remains unchanged throughout the column's existence in that list.

Here is the simplest approch to figure out internal name of a field / column


  1. Go to list's settings page

    List's settings option shown in ribbon's 'List' tab

  2. Click on the field / column name
    Under "Columns" section click on desired column name

  3. Notice the last part of url that says "Field=", the value after that is internal name of fieldCopy all text after "Field=" 
  4. Now decode the value.
    Open http://meyerweb.com/eric/tools/dencoder/ , paste the test, and click on "Decode".
    This is the internal name of field.

That's all, hope you found it helpful.

Wednesday, July 9, 2014

SharePoint 2013 - Access denied error message when accessing anonymous permission list using client side object model or javascript

We had a list having anonymous access but after migrating from 2010 to 2013 we started getting error.
The anonymous permission was there but still getting error.

After searching I found a blog and it helped me in solving this.

This is what I did in my case:
1. Go to site collection
2. Site Seettings > Site Permission
3. Click on "Anonymous Access" in ribbon menu
4. Uncheck "Require Use Remote Interfaces permission"


And it again started working...  :)

Thanks for reading this and I hope someone will be benefited.

Saturday, April 5, 2014

Nintex - HTML to PDF - Force Page Break

Recently we had required to force a page break on converted PDF file from HTML content.

I gave it try with following but did not work:

<table>...</table>
<div style='page-break-after:always;'></div>
<table>...</table>

It looks like using just div does not works, it might be due to that div with no content is not visible on page.
So I applied the css to the table tag and it worked, following is working code:

<table>...</table>
<table style='page-break-before:always;'>...</table>

Hope this will be helpful to someone and save time!

Monday, March 3, 2014

SharePoint 2013 Error Moving Design Package From Office 365 To On Premises

A error occurs when you import Office 365 SharePoint 2013 package to your on premises SharePoint.


Today I faced an error when I moved the branding design form Office 365 SharePoint to on premises.
The error was obvious becuase Office 365 SharePoint is always up to date while on premises not always.

There was two errors, one more Microsoft.SharePoint and other for Microsoft.SharePoint.Publishing.
Following is the exact error message for Microsoft.SharePoint.Publishing
Sorry, something went wrong 
Could not load file or assembly 'Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified


The solution:
The solution is to replace the version number from "16.0.0.0" to "15.0.0.0" on associated html page for Master and Layout page.

Step 1: Correct the version number for Microsoft.SharePoint

I went to associated HTML page and
repalced:
Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

with:
Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

Step 2: Correct the version number for Microsoft.SharePoint and Microsoft.SharePoint.Publishing in associated layout page:

I replaced:
Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Microsoft.SharePoint.Publishing, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

with:
Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

Tuesday, February 25, 2014

Wednesday, February 19, 2014

jQuery - Checkbox Check and Uncheck

There are two ways to check or uncheck checkbox using jQuery
1. The first one by using property

// to check
$('#theCheckbox').prop('checked',true)

// to uncheck
$('#theCheckbox').prop('checked',false)

This sets the property like:

checkboxObject.checked=true;

2. The second one by using attribute

// to check
$('#theCheckbox').attr('checked','checked')

// to uncheck
$('#theCheckbox').removeAttr('checked')


Friday, February 14, 2014

Office 365 SharePoint 2013 - Blog Customization - Show Posts By Author - Part 1

Recently I worked on blog customization project which required to show the posts by authors in Office 365 SharePoint 2013 public facing site blog.

Here is the guide you can use to do same for yourself.
Part 1: Create a page that shows the authors posts
Part 2: Show authors list on left navigation on blog page

Step 1: Get ListId, ListName and WebId from Posts.aspx

Open your site in SharePoint Designer 2013
Go to "All Files" on left and then "Pages" library
Right click on "Posts.aspx" and choose "Edit Fie in Advance Mode"
Use find tool to find "ListId" and then grab the ListId and ListName value
Use find tool to find "WebId" and then grab "WebId" value

Step 2: Make WebPart ready

Download the WebPart and edit it (for example Notepad++).
Replace the ListId, ListName and WebId value that we grabbed in Step1, take a look at following screenshot of replacement done:


Save this WebPart now.

Step 3: Create a page to show author's post

Create a new page and name it "authorposts"
While the page in Edit mode, Go to "Insert" > "WebParts" > "Upload Web Part" and browse to the WebPart that you created in Step2. When prompted click "OK" to save the page.
The WebPart is still not added, once again go to "Insert" tab > "WebPart" >  "Imported Web Parts" > "AuthorPosts.webpart" and finally click on "Add" button (on right)
Now save the page
We are done with this step now, so far we have created a page that has WebPart that actually shows the posts.
Now it turns to show the authors list on the left navigation so that users can browser. Let's move to Part 2

Office 365 SharePoint 2013 - Blog Customization - Show Posts By Author - Part 2


Part 1: Create a page that shows the authors posts
Part 2: Show authors list on left navigation of blog page

Step 1: Download the XSL file and upload it to "Site Assets" library and finally grab the url of that uploded XSL file.

Step 2: Now repeat all the steps mentioned in this step to following pages:

  1. siteurl/Pages/Blog.aspx
  2. siteurl/Pages/Posts.aspx
  3. siteurl/Pages/Post.aspx
Edit the page and click on "Add Webpart" on left navigation

Add "Posts" WebPart

Edit the WebPart
Paste the XSL link in Miscellaneous > XSL Link
Specify title in Appearance > Title
Specify url and description in Advance > Title Url & Advance > Description
(This will help not to user navigate away from the page)

Hit OK and Save the page

SharePoint 2013 Fixed Width Content

I am modifying the oslo.master to show the content in fixed width.

1. Edit the required MasterPage

In SharePoint Designer 2013 open your site.
Click on MasterPage under Objects on left.

Edit the oslo.master

2. Find the div tag having id="s4-workspace"

Add following attribute

class="s4-nosetwidth"


style="margin:1px;"

3. Find the div tag having id="s4-bodyContainer"

Add following attribute

class="s4-nosetwidth"


style="width:960px; margin:0 auto;"

Ensure it looks like following:

Finally save the MasterPage and you are done!

Wednesday, February 5, 2014

SharePoint 2013 REST API - Get File URL From Document And Picture Library

By default RESP API query for document or picture library result does not include file URL, you need to include field FileRef to return it.

https://techamit.sharepoint.com/_api/web/lists/getbytitle('Style%20Library')/items?$select=FileRef,ID

Tuesday, February 4, 2014

SharePoint Branding - Add CSS / Stylesheet to MasterPage And Layout Page

I just wanted to make this small note for myself:

Add stylesheet to MasterPage

Put the code within head tag

<link rel="stylesheet" runat="server" type="text/css" href="<%$SPUrl:~SiteCollection/Style Library/Branding/css/styles.css%>" />

In case of layout pages:


<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">
<link rel="stylesheet" runat="server" type="text/css" href="<%$SPUrl:~SiteCollection/Style Library/Branding/css/styles.css%>" />
</asp:Content>

Monday, February 3, 2014

Nintext Form - Custom Date Input Control

I was assigned to do a Nintext Form and when it came to date of birth input, relaying on date picker control was not a good idea, so decided to take input in custom way.

Here is is how I did it.

Step 1: Create control

Put three controls each for Date, Month and Year
Date and Year is Textbox
Month is dropwown list. Open settings for this dropdown and specify choices with following and also specify first choice as default value otherwise dropdown will have "Please selection one..." as first option.
01 (Jan)
02 (Feb)
03 (Mar)
04 (Apr)
05 (May)
06 (Jun)
07 (Jul)
08 (Aug)
09 (Sep)
10 (Oct)
11 (Nov)
12 (Dec)

Step 2: Assign CSS class to controls

Nintext default date picker control: custom-dob
Date control: custom-dob-dd
Month control: custom-dob-mmm
Year control: custom-dob-yyyy

Step 3: Add Javascript to Form's settings

Bring up the form's settings by going to tab Nintext Forms  > Settings
Paste following code in "Custom Javascript" section input box.

// Update Nintext DOB calendar control on input / chages of our custom control
var customDateInput = [];

NWF$(document).ready(function () {
    customDateInput.push({
        dt: NWF$('.custom-dob input'),
        d: NWF$('.custom-dob-dd input'),
        m: NWF$('.custom-dob-mmm select'),
        y: NWF$('.custom-dob-yyyy input'),
        format: 'dmy'
    });
});

function CustomDateInputHandler(idx) {
    // This function updates the date picker control
    // Find the controls from collection
    var item = customDateInput[idx];
    // Get date,month and year
    var d = item.d.val();
    var m = item.m.prop('selectedIndex') + 1;
    var y = item.y.val();
    // Build the date in specified format
    var dt;
    if (item.format==='mdy'){
        dt = m + '/' + d + '/' + y;
    }
    else if (item.format==='ymd'){
        dt = y + '/' + m + '/' + d;
    }
    else{
        dt = d + '/' + m + '/' + y;
    }
    // Update date picker control
    item.dt.val(dt);
}
NWF$(document).ready(function () {
    if (customDateInput.length === 0) return;
    for (var i = 0; i < customDateInput.length; i++) {
        curItem = customDateInput[i];
        // Save index of this item in attribute
        curItem.d.attr('custom-date-index', i);
        curItem.m.attr('custom-date-index', i);
        curItem.y.attr('custom-date-index', i);
        
        // Bind change event to date,month and year.
        // On change it will call a function with index
        // in the collection
        curItem.d.change(function () {
            CustomDateInputHandler(NWF$(this).attr('custom-date-index'))
        });
        curItem.m.change(function () {
            CustomDateInputHandler(NWF$(this).attr('custom-date-index'))
        });
        curItem.y.change(function () {
            CustomDateInputHandler(NWF$(this).attr('custom-date-index'))
        });
    }
});


Save the form and test if changing custom control is updating default datepicker control value correctly.

Step 4: Hide default datepicker control

Open the form's setting page by going to tab Nintext Form > Settings
Paste following code in "Custom CSS" section input box:

.custom-dob{
   visibility:hidden;
}


Here is design and final rendered look of the test form:

If more than one control is required

If you want to have more than 1 custom date picker, you need to copy the following code and replace the css class with your own. Also, take a look at the screenshot below:
The code you can use:

customDateInput.push({
    dt: NWF$('.custom-dob input'),
    d: NWF$('.custom-dob-dd input'),
    m: NWF$('.custom-dob-mmm select'),
    y: NWF$('.custom-dob-yyyy input'),
    format: 'dmy'
});

Changing the format of date

You might have notice format: 'dmy', you can change the value of dmy to following:
  1. dmy for d/m/yyyy
  2. mdy for m/d/yyyy
  3. ymd for yyyy/m/d

Sunday, February 2, 2014

WebPart Gallery Url - SharePoint 2010 / 2013

I could not found a link to navigate to webpart gallery in Office 365 SharePoint 2013 public facing site.
After searching I found a blog where it was listed, thanks to: http://heathersolomon.com/blog/articles/1116.aspx

/_catalogs/wp/Forms/AllItems.aspx



Saturday, February 1, 2014

Load jQuery If Not Loaded

The following script loads the jQuery from specified source if jQuery is not already loaded on page.

You need to call the function ensurejQuery with parameter of source jQuery to used.
Example:

ensurejQuery('http://code.jquery.com/jquery-1.11.0.min.js');


The complete code:

function ensurejQuery(src) {
    if (typeof window['jQuery'] == 'undefined') {

        // if HTML5 url
        if (src.substring(0, 2) === '//') {
            writeScriptTag(src);
            return;
        }

        // If this page is requested as secure ('https://') 
        // use same for script source
        if (location.protocol === "https:" && src.substring(0, 6) !== 'https:') {
            var httpsUrl = src.replace('http://','https://')
            writeScriptTag(httpsUrl);
            return;
        }

        writeScriptTag(src);
    }
    function writeScriptTag(jslocation) {
        document.write('<scr' + 'ipt type="text/javascript" src="' + jslocation + '"></sc' + 'ript>');
    }

}

// Example:
// ensurejQuery('http://code.jquery.com/jquery-1.11.0.min.js');







Friday, January 31, 2014

Office 365 SharePoint 2013 - Blog Customization - List By Year

I got an opportunity to customize the Office 365 SharePoint 2013 Blog customization.

Here is how you can show the years list for blog like "Archive" and "Category"

This post is demonstrated on video: http://youtu.be/CN9Knr5SUxQ
The XSL file you need.
Here is the XSL code:

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
 <xsl:output method="html" indent="no"/>
 <xsl:decimal-format NaN=""/>
 <xsl:param name="dvt_apos">'</xsl:param>
 <xsl:param name="ManualRefresh"></xsl:param>
 <xsl:variable name="dvt_1_automode">0</xsl:variable>
 <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
        <xsl:call-template name="dvt_1"/>
 </xsl:template>
 
 <xsl:template name="dvt_1">
  <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
  <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
  <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
  <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
  <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
  
  <xsl:choose>
   <xsl:when test="$dvt_IsEmpty">
    <xsl:call-template name="dvt_1.empty"/>
   </xsl:when>
   <xsl:otherwise>
    <ul class="ms-core-listMenu-item static ms-noList link-style1">
     <xsl:call-template name="dvt_1.body">
      <xsl:with-param name="Rows" select="$Rows"/>
     </xsl:call-template>
    </ul>
   </xsl:otherwise>
  </xsl:choose></xsl:template>
 <xsl:template name="dvt_1.body">
  <xsl:param name="Rows"/>
  <xsl:for-each select="$Rows">
   <xsl:call-template name="dvt_1.rowview" />
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="dvt_1.rowview">
        <xsl:variable name="PostDateFormatted" select="ddwrt:FormatDate(@PublishedDate,1033,1)"/>
        <xsl:variable name="PostYear" select="substring(substring-after(substring-after($PostDateFormatted,'/'),'/'),1,4)"/>   
    <xsl:variable name="NewGroup" select="ddwrt:NameChanged(string($PostYear), 0)" />
    <xsl:if test="string-length($NewGroup)">
  <li class="static linkitem">
   <a class="ms-core-listMenu-item">
    <xsl:attribute name="href">
    <xsl:value-of select="concat('/Blog/Date/',$PostYear)"/>
    </xsl:attribute>
    <xsl:value-of select="$PostYear"  />
   </a>
  </li>
  </xsl:if>
 
 </xsl:template>
 <xsl:template name="dvt_1.empty">

 </xsl:template></xsl:stylesheet>


Step 1

Go to your blog site and edit the page


Step 2

Insert "Post" webpart

Step 3

Speicify XSL file in webpart settings


Step 4

Specify a proper title to webpart

Step 5

Update "Title URL" & "Description" so that clicking on webpart title don't take anywhere and a description that user will when mouse over to webpart title

Done!




Office 365 SharePoint 2013 Public Site - Allow Anonymous Users

I created the public facing site on Office 365 SharePoint 2013 but when I tried to access the site as anonymous user, I was redirected to authentication page.

I went to Site Permission settings, Anonymous permission was not there.

I started looking around for an option that could make the site open for anonymous and found this options that made the site open for anonymous. This option can also be used to take off from anonymous users:

Make Website Online option



Thursday, January 30, 2014

SharePoint 2013 Left Navigation Gets Hidden When Using Bootstrap 3

I was branding SharePoint 2013 and using Bootstrap 3.
When I gave QuickLaunch / Left Navigation to col-md-3 and main content to col-md-9, suprisingly on lower screen when it supposed to display full width it was getting hidden.

I figured out that QuickLaunch menu was floating on left by default so it was causing issue.

Here is the fix:
#sideNavBox{
    float:none;
}

Hope it will help someone!


Sunday, January 26, 2014

SharePoint 2013 oData query _ModerationStatus field

Today I found some of the field whose internal name starts with a underscore chracter ("_") has "OData_" prefix that makes it  OData__ModerationStatus.
This prefix is only appears in oData query result.


The this link for list of special fields: http://blogs.msdn.com/b/michael_yeager/archive/2008/11/03/reference-list-for-internal-field-names.aspx


Saturday, January 18, 2014

ItemStyle.xsl - Clickable Title Showing Default View Form In Modal

This is customized item template for ItemStyle.xsl SharePoint 2013 CQWP showing only clickable title that shows default view form in modal. You can just copy and paste in ItemStyle.xsl file at the bottom (of course before </xsl:stylesheet> :) ) to test it:



<xsl:template name="ItemTitlePoupView" match="Row[@Style='ItemTitlePoupView']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
        <xsl:call-template name="OuterTemplate.GetSafeLink">
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        </xsl:call-template>
    </xsl:variable>             
    <p class="anntitle">
        <a>
            <xsl:attribute name="href">
              <xsl:value-of select="concat(&quot;javascript:SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', {url:'&quot;,$SafeLinkUrl,&quot;'})&quot;)"/>
            </xsl:attribute>                   
            <xsl:value-of select="@Title"/>
        </a>
    </p>
</xsl:template>




SharePoint 2013 CQWP ItemStyle.xsl - Match today's date

Following code demonstrate how we can match "Modified" date of an announcement and output if date is today rather than show date. 

List of LCID: http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
For list of LCID and Format also thanks goes to this blog:  http://blogs.msdn.com/b/joshuag/archive/2009/03/25/custom-date-formats-in-sharepoint-xsl.aspx


<xsl:variable name="AnnModifiedDate" select="ddwrt:FormatDate(@Modified,3081,1)"/>
<xsl:variable name="TodayDate" select="ddwrt:FormatDate(ddwrt:Today(),3081,1)"/>
<span class="anndate">
  <xsl:choose>
    <xsl:when test="$AnnModifiedDate = $TodayDate">
      <xsl:text>
        Today
      </xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$AnnModifiedDate"/>
    </xsl:otherwise>
  </xsl:choose>
</span>



Explanation:
This code converts the Modified and Current date to Australian date format (d/m/yyyy) and does the match.
If matched outputs "Today" else the date.

SharePoint 2013 - ItemStyle.xsl - How to get today's date

I was wondering how I can get today's date to use in customization of ItemStyle.xsl, here it is:

Put it in a variable:
<xsl:variable name="TodayDate" select="ddwrt:Today()"/>

Another example to create a span tag:
<span class="todaydate">
<xsl:value-of select="ddwrt:Today()"/>