onsdag den 28. marts 2012

JavaScript and Client Object Model - Get Latest Video Pages

SharePoint Apps



//initiates function SetLabelValues on page load:

ExecuteOrDelayUntilScriptLoaded(GetValues, "sp.js");

function GetValues()
{

//Get context - video site

var ctx = new SP.ClientContext("/videositename/");

//Get web:

var web = ctx.get_web();

//Get list

var videoList = web.get_lists().getByTitle('Pages');

//Get the latest video
var caml = new SP.CamlQuery();


this.allVideos = videoList.getItems(caml);

//Video is a custom site column
ctx.load(this.allVideos, "Include(Title,Video,Created, Comments,FileRef)");

//Video List
var enumerator = this.allVideos.getEnumerator();

while (enumerator.moveNext()) {

var li = enumerator.get_current();
var videourl = li.get_item("FileRef");
var videotitle=li.get_item("Title");
//build the str string here...
}

//Write list to a div tag with id="VideoList"

var div = document.getElementById("VideoList");
div.innerHTML = str;
}

Ingen kommentarer:

Send en kommentar