Where is the Sharepoint 2013 JavaScript Object Model Reference

We have invested in Sharepoint 2013 and I'm trying to write some customised Display Templates.

A sample of the code I am working on appears below.

I was struggling with some aspects of this, to the extent that I required an MS Support Paid Incident to resolve a simple issue like surfacing Managed Meta Data. That issue took an MS Support engineer around 2 weeks to resolve.

I am now experiencing additional problems, specifically trying to understand the values and properties that are returned from the Ctx.CurrentItem.XXX methods and objects.

I have done a lot of Googling and come to the conclusion that what I am looking for is the Sharepoint 2013 JSOM Reference. However, somewhat frighteningly, this does not appear to exist? I have been able to find some pages that show samples of how the JSOM can be used, but it seems that the Reference itself has never been released? Can anybody point me to a link, or confirm for me that, as yet, the Reference is not available?

By way of clarification, I am looking for the official reference that explains in detail each of the methods and properties and what types of data they return etc.

For an example of what I mean by Reference - , in .NET Framework, if I want specific documentation on the FileInfo class, I can look here:

http://msdn.microsoft.com/en-us/library/system.io.fileinfo(v=vs.100).aspx

and I see an exact definition of the class, its method and properties that are available, together with specific documentation as to exactly what they do, what will be returned etc. That's what I mean by Reference - the actual official technical documentation for the product.

Where can I find this information for the JSOM for Sharepoint 2013?

I need to understand, for example, what is returned by ctx.CurrentItem.ContentType - at the moment, I am guessing that it returns an array of some type, but I am just having to guess based on the code I am writing and how it behaves. I am basically developing with a trial & error mentality, because I have no other information. Where I can find the information that I need?

I have already been through the following pages and their corresponding links, but none points to any official reference or the information I am looking for:

http://msdn.microsoft.com/en-us/library/jj163201.aspx

http://msdn.microsoft.com/en-us/library/ee552096.aspx

These talk about the object model, how it can be used, and talk about where to find various .js files. But nowhere is there any links to documentation of the model itself?

Where can I find information about the ctx Object and the methods and properties that I can use with it, when working with Customised Display Templates?

Has this documentation ever been released?

Thanks

Robert

<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> 
<head>
<title>PDF Item Full Preview 4</title>

<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">Displays a result tailored for a Portable Document Format (PDF) document.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','Path':'Path','Description':'Description','EditorOWSUSER':'EditorOWSUSER','LastModifiedTime':'LastModifiedTime','CollapsingStatus':'CollapsingStatus','DocId':'DocId','HitHighlightedSummary':'HitHighlightedSummary','HitHighlightedProperties':'HitHighlightedProperties','FileExtension':'FileExtension','ViewsLifeTime':'ViewsLifeTime','ParentLink':'ParentLink','FileType':'FileType','IsContainer':'IsContainer','SecondaryFileExtension':'SecondaryFileExtension','DisplayAuthor':'DisplayAuthor','ContentType':'ContentType','SPContentType':'SPContentType'</mso:ManagedPropertyMapping>
<mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile>
<mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">http://dev8spt/_catalogs/masterpage/Display Templates/Search/Item_PDF_FullPreview.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
    <div id="Item_PDF">

<!--#_ 
        if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){

			var id = ctx.ClientControl.get_nextUniqueId();
            var itemId = id + Srch.U.Ids.item;
			var hoverId = id + Srch.U.Ids.hover;
			var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_PDF_FullPreview_HoverPanel.js";
			$setResultItem(itemId, ctx.CurrentItem);
			var k = ctx.DataProvider.get_currentQueryState().k;
			if(!Srch.U.e(k)){
				ctx.CurrentItem.csr_Path = ctx.CurrentItem.Path + "#search=" + $urlKeyValueEncode(k);
			}
            ctx.CurrentItem.csr_Icon = Srch.U.getIconUrlByFileExtension(ctx.CurrentItem);
            ctx.CurrentItem.csr_OpenControl = "PdfFile.OpenDocuments";
            ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
            ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();

			if($isNull(ctx.CurrentItem.ContentType)){ 
_#-->
						<div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
							_#=ctx.RenderBody(ctx)=#_
							<div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
						</div>
<!--#_ 
			}
			else
			{
				switch(ctx.CurrentItem.ContentType)
				{
				
				          application/pdf Architect Record
					case "application/pdf Architect Record":
_#-->
						<div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
<table>
<tr>
<td>
Icon
</td>
<td>
RegistrationNumber  Surname  Forenames
</td>
</tr>
<tr>
<td>Content Type
</td>
<td>ArchitectsRecordCategory   Name
</td>
</tr>
</table>
					<div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
						</div>
<!--#_ 
						break;
					default:
_#-->
						<div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="PDFItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
							_#=ctx.CurrentItem.ContentType=#_
							_#=ctx.RenderBody(ctx)=#_
							<div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
						</div>
<!--#_ 
						break;
				}
			}
        } 
_#-->
    </div>
</body>
</html>

March 14th, 2013 12:53pm

*bump*

anyone know where I can find any documentation on the JSOM?

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2013 2:03pm

Here: http://msdn.microsoft.com/en-us/library/jj193038.aspx
March 18th, 2013 11:37am

Hi

Thanks, but No. I'm puzzled as to why this was marked as the answer.

I am looking for the Reference which explains, for example, the various different methods and properties you see used in my sample code.

For example

ctx.CurrentItem.csr_Icon

 ctx.CurrentItem.csr_OpenControl

 ctx.ClientControl.get_nextUniqueId()   etc.

I stand happily to be corrected but the API reference to which you refer does not document any of this.

Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2013 3:55pm

*bump*

would be really grateful if anyone knows where I can find this information

thanks

March 23rd, 2013 7:02pm

See this page, it has some code snippets.

http://msdn.microsoft.com/en-us/library/jj163201.aspx

Also check the below page, it lists some code examples. You will find that subject column tags each sample for API used.

http://msdn.microsoft.com/en-us/library/jj901637.aspx

Free Windows Admin Tool Kit Click here and download it now
March 24th, 2013 11:57am

Hi

Thanks for this.

I'm really tempted to mark yours as the Answer, since this is the first time I have ever seen any official documentation from Microsoft that even mentions "ClientContext"

To work with websites using JavaScript, start by using the ClientContext(serverRelativeUrl) constructor and pass a URL or URI to return a specific request context.

So it may be that we're getting closer to answering the question

If a couple of code snippets is the best anyone can come up with, would you agree with me by implication that the proper, full documentation/reference doesn't exist yet and hasn't been released?

Given that no one can turn it up, I'm guessing it simply is not available, and that anyone developing on SP2013 is in fact developing completely in the dark at present.

What would be amazingly helpful would be to have the Microsoft SP team confirm that this is the case and/or provide a release date for the documentation.

 

March 24th, 2013 4:38pm

*Bump*

anyone?

Free Windows Admin Tool Kit Click here and download it now
March 25th, 2013 3:03pm

Robert, probably you're in the dark, but you're not alone!

Same need here modifying some Display Templates for SPS2013.... is like go back to the 90's

April 2nd, 2013 2:45pm

Is this what you're looking for (JS reference for ClientContext object)?

http://msdn.microsoft.com/en-us/library/jj245759.aspx

Free Windows Admin Tool Kit Click here and download it now
April 2nd, 2013 7:44pm

I'll add a bump here too. We need details not only on the ctx.CurrentItem (which is not the same as ClientContext) but also how to use the whole Srch.U namespace. It appears that there are a number of utility functions in here.

Show us the documentation.

M

May 5th, 2013 11:57am

hehe good luck!

Best documentation: go in 15 hive folder and make a deep dive yourself with the javascript files :(

I have the exactly same problems so i follow this thread...

  • Proposed as answer by stephane-stbzn Saturday, July 13, 2013 10:13 AM
  • Unproposed as answer by stephane-stbzn Saturday, July 13, 2013 10:13 AM
Free Windows Admin Tool Kit Click here and download it now
June 28th, 2013 10:02pm

hehe good luck!

Best documentation: go in 15 hive folder and make a deep dive yourself with the javascript files :(

I have the exactly same problems so i follow this thread...

  • Proposed as answer by stephane-stbzn Saturday, July 13, 2013 10:13 AM
  • Unproposed as answer by stephane-stbzn Saturday, July 13, 2013 10:13 AM
June 28th, 2013 10:02pm

Hi

I face with the same search as you.

Without any answer !

I'll chech the tread too.

Stephane

Free Windows Admin Tool Kit Click here and download it now
July 13th, 2013 10:14am

*bump*

December 16th, 2013 2:46pm

**bump**

Is the documentation available yet?

Free Windows Admin Tool Kit Click here and download it now
November 17th, 2014 3:07pm

I'm also waiting for an answer to this question.
November 25th, 2014 1:46pm

Also looking for ctx.CurrentItem details.
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 1:12pm

**bump**

Is the documentation available yet?

After more than 2 years, I'm guessing probably not, but maybe worth a bump.

June 26th, 2015 8:47am

Hi RobertEllis3,

Instead of searching 2 years, If I were I would have tried to explore the black box of this "DisplayTemplates".
How to use the Javascript variable.

How to use the "use strict" how to identify what would be the data type when the function called on the page by using quick watch,debug and command window.

How to be the mastering the F12 controls in IE.
How the javascript functions for the SharePoint 2013 has been constructed by using IL & Spy or dis-assembler.

If you know all these and tried to explore you would have been amazed to come up with your own solution.

Just check this http://blogs.technet.com/b/tothesharepoint/archive/2013/09/05/understand-how-item-display-templates-and-hit-highlighting-work-in-sharepoint-server-2013.aspx

I would suggest you to look in to header "About important elements in the item display template" in above ar

Free Windows Admin Tool Kit Click here and download it now
June 26th, 2015 11:58am

Thanks for the response.

Obviously, I haven't been looking for two years. I gave up a long time ago, but thought I'd bump to see if anything has changed.

Of course, delving in and exploring is a great way to learn, as you have kindly pointed out.

On the other hand, in the real world of needing to design and deliver solutions for customers in time-sensitive fashion, documentation of the software stack solution providers need to develop against would be quite handy, don't you think? 

Maybe it's just me, but it seems like a glaring omission in what is, after all, an extremely expensive product to license.

Just my 2 cents :-)

June 30th, 2015 6:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics