CSOM – Client Side Objet Model

SharePoint hosted app.

getSiteCollection = function () {
   context = new SP.ClientContext.get_current();
   siteCollection = context.get_site();
   context.load(site);
   context.executeQueryAsync(onSuccess, onFailure);
},
onSuccess = function () {
   alert(“URL: ” + siteCollection.get_url());
},
onFailure = function(sender, args) {
   alert(“Could not obtain the site collection URL”);
}

Elements.xml

Hierin definieer je in welke group een webpart komt.

get_current();

Haalt de huidige SP context op waar de code in ‘draait’, zodat je niet moeilijk hoeft te doen om een connectie met SP te maken. met site = context.get_site();  haal je vervolgens de huidige site op

 

loading objects

twee opties:

  1. context.load();                                ; haalt het hele object op b.v. site of list
  2. context.loadQuery();                     ; haalt een deel op – handig bij lijsten/sites die véél data bevatten

Execution

executeQueryAsync();                             ; onSuccess, onFailure

 

Project starten

File – new – project – templates – visual c# – office/sp

local sp solution: SharePoint Solution – SP 2013 empty project