Pages

Monday, May 26, 2014

Determine which SharePoint Version the Site

Basically we can go with step wise as initial step looking for default css files. 
  • SharePoint 2013 will have corev15.css. 
  • SharePoint 2010 will have corev4.css
If you dont find those , please click F12 and open up the Developer tools. In that go to  Network tab and look for MicrosoftSharePointTeamServices in the response headers of the site.
  • For SharePoint 2010 sites --> MicrosoftSharePointTeamServices --> 14.0.0.6114 
  • For SharePoint 2013 sites --> MicrosoftSharePointTeamServices --> 15.0.0.4420
  • Below is detailed report for MOSS 2007

12.0.0.6535 MOSS 20071 or WSS 3.0 SP2 + December 09 cumulative Update (KB960010 + KB960011)
12.0.0.6524 MOSS 20071 or WSS 3.0 SP2 + 15th December Update (KB977027 + KB977026)
12.0.0.6520 MOSS 20071 or WSS 3.0 SP2 + October 09 cumulative Update (KB974989 + KB974988)
12.0.0.6514 MOSS 20071 or WSS 3.0 SP2 + August 09 cumulative Update (KB973400 + KB973399)
12.0.0.6510 MOSS 20071 or WSS 3.0 SP2 + June 09 cumulative Update (KB971538 + KB971537)
12.0.0.6504 MOSS 20071 or WSS 3.0 SP2 + April 09 cumulative Update (KB968850 + KB968851)
12.0.0.6421 MOSS 20071 or WSS 3.0 SP2 (KB953338 + KB953334) [Updated 1st Aug 09: SP2 download now includes the hotfix (KB971620) that corrects the activation issue more information on the Microsoft SharePoint team blog]
12.0.0.6341 MOSS 20071 or WSS 3.0 February 09 cumulative Update (KB961755 + KB961756)
12.0.0.6335 MOSS 20071 or WSS 3.0 December 08 cumulative Update (KB960010 + KB960011)
12.0.0.6331 MOSS 20071 or WSS 3.0 October 08 cumulative Update (KB957691 + KB957693,KB958567 and KB958569)
12.0.0.6327 MOSS 20071 or WSS 3.0 August 08 cumulative update (KB956056 & KB956057)
12.0.0.6318 MOSS 20071 or WSS 3.0 Infrastructure Update (KB951695 & KB951297)
12.0.0.6303 MOSS 20071 or WSS 3.0 post-SP1 hotfix (KB948945)
12.0.0.6301 MOSS 20071 or WSS 3.0 post-SP1 hotfix (KB941274)
12.0.0.6300 MOSS 20071 or WSS 3.0 post-SP1 hotfix (KB941422)
12.0.0.6219 MOSS 20071 or WSS 3.0 SP1
12.0.0.6039 MOSS 20071 or WSS 3.0 October public update
12.0.0.6036 MOSS 20071 or WSS 3.0 August 24, 07 hotfix package
12.0.0.4518 MOSS 20071 or WSS 3.0 RTM
12.0.0.4407 MOSS 20071 or WSS 3.0 Beta 2 TR
12.0.0.4017 MOSS 20071 or WSS 3.0 Beta 2
12.0.0.3111 Office 12 (PDC image - pre-beta) - This version of Office does not have a support link in the Add/Remove programs dialog box.


Will Keep posting if I find any more info on this.

Wednesday, May 21, 2014

SharePoint 2013 JSLink Not working on Taxanomy Field - Workaround Solution

Overriding JSLink property via field xml definition or c# code is a nice way to link your JavaScript file to the particular field. However, not all the fields could be overwritten this way.
For example, Taxonomy field has the following JSLink definition
// Microsoft.SharePoint.Taxonomy.TaxonomyField
public override string JSLink
{
    get
    {
        return "SP.UI.Taxonomy.js|SP.UI.Rte.js(d)|SP.Taxonomy.js(d)|ScriptForWebTaggingUI.js(d)";
    }
}
?
This means you cannot modify the look and feel for your Taxonomy field. Also, you can’t do that for Taxonomy, Related Items or Task Outcome field. All of these fields return particular JSLink which can’t be changed.
Frankly saying, you still may change look and feel of these fields, but you need to register your JavaScript file on the site collection level and make sure it gets loaded on every page. It could be done with custom action or any other methods to deliver JavaScript file within the site collection scope.

Tuesday, May 20, 2014

SharePoint 2013 JSLink Not working on LinkTitle Column - Workaround Solution

When I applied JSlink for LinkTitle Column I am not able to see the JS is loading at all. But all for other Columns and my custom columns too I can apply.
Is their any difference over here..Yes it is..The workaround for this is
Below is demonstrated how to customize LinkTitle column rendering
1) Create template
(function () {


   function titleRenderer(ctx) {
       var item = ctx.CurrentItem;
       return '<img src="/SiteAssets/' +  item.Title + '.png" />';  
    }



    function registerRenderer()
    {
      var context = {};
      context.Templates = {};
      context.Templates.Fields = {
        "LinkTitle": {
            "View": titleRenderer
        }
      };

      SPClientTemplates.TemplateManager.RegisterTemplateOverrides(context);
    } 
    ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');

})();
where we override LinkTitle field rendering
2) Upload template file into, for example, Site Assets library
3) Specify JS Link property for List View web part Example: ~site/SiteAssets/Phones.js

Sameway if you see issues in any of the below fields please follow with above way,
 //ID,PermMask,FSObjType,HTML_x0020_File_x0020_Type,ContentType,File_x0020_Type,
 //File_x0020_Type.mapapp,HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon,
 //HTML_x0020_File_x0020_Type.File_x0020_Type.mapico,serverurl.progid,
 //ServerRedirectedEmbedUrl,File_x0020_Type.progid,File_x0020_Type.url,
 //FileRef,FileLeafRef,CheckoutUser,CheckedOutUserId,IsCheckedoutToLocal,Title,
 //Created,Created.FriendlyDisplay,firstRow

Monday, May 19, 2014

Verify SPUtility.SendMail is working or not

Generally once we configure the Incoming/Outgoing Mail settings in Central Admin, we assume that now from SharePoint Object Model we can send an mail. For this we use the SPUtility.SendMail Method, but in some cases it fails and mail will not be send. In order to verify as a quick step, you can do send an email from Powershell using the same Namespace and Method. If this works fine, then it is 99% sure that it works from our Code.


$email = "test@sharepoint.com"
$subject = "Verify Send Mail"
$body = "Hello..Welcome to SharePoint"

$site = New-Object Microsoft.SharePoint.SPSite "http://sharepoint"
$web = $site.OpenWeb()
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,0,0,$email,$subject,$body)

// A True or False will confirm the message has been sent or not

SharePoint 2013 Client People Picker Control

The SharePoint Client People Picker control looks very good and gives end user easy of selecting the targeted user with its dynamic drop down list of keyed characters.

To use this in normal way, it looks pretty easy too. Paste the below code and it works fine as expected.

<SharePoint:ClientPeoplePicker
Required="true"
ValidationEnabled="true"
ID="pplPickerSiteRequestor"
UseLocalSuggestionCache="true"
PrincipalAccountType="User"
runat="server"
VisibleSuggestions="3"
Rows="1"
AllowMultipleEntities="false"
CssClass="ms-long ms-spellcheck-true user-block"
ErrorMessage="*" 
/>

I am not sure whether its a bug or desgined as per client side for OOB forms. Here I faced a challenge where I require in this control user need to allow for Only One User.

The problem is if user enters second user it should restrict and should not submit the form. Basically if you observe the attribute AllowMultipleEntities="false" as developer we think it will takecare of. But this happens the half way, like it submits the form but in the server side you will get only one user. In order to avoid this, I embedded a custom validator and controlling the form to not to submit if more than one user is there. 

Below is the snippet code for it.

<asp:CustomValidator ID="cvpplSiteRequestor" runat="server" ControlToValidate="pplPickerSiteRequestor" ForeColor="Red" 
ClientValidationFunction="CheckSiteRequestor" 
ErrorMessage="User is a required field" ValidationGroup="SiteAccessForm" Text="*"></asp:CustomValidator>

Javascript Code:-

function CheckSiteRequestor(sender, args) {
args.IsValid = false;
var userCount = $("span.ms-entity-resolved").length; //Returns the Resolved User Name 's Count

if (userCount === 1) {
args.IsValid = true;
}
}


Here I do have another requirement where having Clear Button, which should clear all input form elements. For this Client People Picker, we dont have any default attribute or function. Below is the code snippet which will make sure the OOB feature is residing.

Javascript Code:-

function ClearFields() {

$("#<%= pplPickerSiteRequestor.ClientID %>_TopSpan_EditorInput").attr('placeholder', 'Enter a name or email address...');

$("#<%= pplPickerSiteRequestor.ClientID %>_TopSpan_InitialHelpText").css("display", "none");

var processedUserListCount = $(".sp-peoplepicker-userSpan").length;

for (var i = 0; i < processedUserListCount; i++)
SPClientPeoplePickerProcessedUser.DeleteProcessedUser($(".sp-peoplepicker-userSpan")[0]);
}

Friday, May 9, 2014

Configure Custom Access Denied Page - BUG in SharePoint 2013

There are many reasons that lead to the need to have your own Custom Access Denied Page, such as changing the text of the message or adding a more dynamic page / form to collect information from the user or perform some other function. Once you build your page and get it deployed to Layouts Folder and use below Powershell Commands


We can use the following PowerShell command for it

$web = Get-SPWebApplication http://WebApplicationURL/
Set-SPCustomLayoutsPage -Identity AccessDenied –RelativePath "/_layouts/15/Folder/CustomAccessDeniedPage.html" -WebApplication $web

Or

$web = Get-SPWebApplication http://WebApplicationURL/
$web.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied, "/_layouts/15/Folder/CustomAccessDeniedPage.html ")
$web.Update()

Check the set property with below PowerShell command

$web = Get-SPWebApplication http://WebApplicationURL/
Get-SPCustomLayoutsPage -Identity AccessDenied -WebApplication $web | Format-List

You will observe the updated Value but when you try browsing you will get the default AccessDenied Page but not the custom access denied page. This is a known bug in SharePoint 2013 product. Till now with the current release of CU1 in Feb 2014, this issue is not been fixed.


Inorder to accomplish this, you can go with HttpHandler or HttpModule. Here we preferred to go with HttpModule and below is the code snippet for it.


public class CustomAccessDenied : IHttpModule
{
public void Init(HttpApplication app)
{
app.PreRequestHandlerExecute += new EventHandler(app_PreRequestHandlerExecute);
}
void app_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
string str = Path.GetFileName(new Uri(context.Request.Url.AbsoluteUri).LocalPath);

if (str.ToLower().Equals("accessdenied.aspx"))
{
context.Response.Redirect("/_layouts/15/customaccessdenied.aspx",true);
}
}

public void Dispose()
{
}
}


Note:- The custom access denied page [aspx] should has to Inherit from "Microsoft.SharePoint.ApplicationPages.AccessDeniedPage" class.
e.g. <%@PageLanguage="C#"Inherits="Microsoft.SharePoint.ApplicationPages.AccessDeniedPage"MasterPageFile="~/_layouts/simple.master"%>

Now write your c# code inline in PlaceHolderMain in the .aspx page. (This is the drawback).