SharePoint 2013 Javascript Object Model


Published on

Presented at SharePoint TechFest Dallas 2014. All rights reserved.

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

SharePoint 2013 Javascript Object Model

  1. 1. Revised 04/29/2014
  2. 2. Topics How to create a Declarative Deployment Solution Benefits and Limitations of JSOM Why context is so important? My favorite JSOM Development Pattern Leveraging JSOM to deliver business solutions through SharePoint
  3. 3. APP vs Solution Provider-hosted apps: App written in provider’s choice of language is hosted on a dedicated server or third-party hosting service. SharePoint-hosted apps: App written in HTML and JavaScript is hosted by SharePoint.
  4. 4. APP vs. Solution continued Declarative Solutions: Visual Studio provides a mechanism for creating a Declarative Solution that is invoked by utilizing the Sandbox Solution project type and selecting to not include an assembly within the package. Note this configuration supports deployment of JavaScript files, style sheets, and xml markup files like those used to create custom actions and site columns but does not support C# code. Publishing creates a .wsp file that can be used to load into the site collection solution store.
  5. 5. Benefits Limitations  Deploys to both O365 and On-Premises Can’t break SharePoint farm Easy to implement/prototype UX designs Faster time to market Its asynchronous and therefore slower Objects have to be requested Entire object model is not implemented No feature receivers Pay attention to what is in your CONTEXT!
  6. 6. Why context is so important? With server-side C# farm solutions you create an instance of an object and you have all of its properties and members available. With client-side JSOM (actually any language) you request an object and you get nothing unless you load it into your context. With SharePoint’s implementation of the client side libraries instantiating an object is not enough, certain properties and members must be requested explicitly.
  7. 7. Singleton Single Object Namespacing with Object Literal Notation Pattern Only one instance of the object on the page Uses a single global variable to reference an object The object contains a collection of key:value pairs with a colon separating each pair of keys and values Syntax requires a comma to be used after each key:value pair with the exception of the last item in your object
  8. 8. "use strict"; var myclassname= { properties: { global1: null, global2: null }, init: function () { // Wires up local properties }, load: function () { // request items and load in to globa1 and global2 } }
  9. 9. <script> SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myclassname.init); </script>
  10. 10. DEMO Code Sample: Live Tiles
  11. 11. DEMO Code Sample: Asset Gallery
  12. 12. Scott Tarnell Solution Principal SLALOMCONSULTING Glassdoor Best Places to Work 2014 Dallas Business Journal Best Places to Work 2013 Microsoft Global Office 365 Solution Partner of the Year 2012 5080 Spectrum Drive, Suite 650E Addison, TX 75001 972.419.2800 main | 972.379.7534 mobile
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.