CHunky Universe of Vigourous Astonishing SHarepoint :)

javascript API i Sharepoint

Det är supersmidigt. Här är ett exempel:


function createAnnouncement(title, body) {
    var ctx = new SP.ClientContext.get_current();
    var list = ctx.get_web().get_lists().getByTitle('Meddelanden');
    var itemCreationInfo = new SP.ListItemCreationInformation();
    this.newListItem = list.addItem(itemCreationInfo);
    this.newListItem.set_item("Title", title);
    this.newListItem.set_item("Body", body);
    Function.createDelegate(this, this.onSucceededCallback), Function.createDelegate(this, this.onFailedCallback));

function onSucceededCallback(sender, args) {
    SP.UI.Status.addStatus("Info", "It worked!",true);
function onFailedCallback(sender, args) {
    SP.UI.Status.addStatus("Info", "It didn't work!",true);

3 responses to “javascript API i Sharepoint

  1. westerdaled 2013-02-22 at 13:30


    Good post. I have a related question. If you wanted a number of pages to all reuse a csom js function that populates a list object based on unique CAML query set on the page via the method shown below.

    The only thing is that there seems no way for onSucceededCallback to pass back the list or array or json array or whatever to the page that requested it. So am I cursed with the burden of having an individual OnSucceededCallback per each page.

    function getListItemsForCategory(subMenuCat) {

    context.executeQueryAsync(onSucceededCallback, onFailedCallback);

    return mypopulatearrayorwhatever


  2. Anatoly Mironov 2013-02-22 at 17:57

    Hi. If there are some variables in OnSucceededCallback, just make them to parameters. Post some more code if you want a more detailed answer 🙂

  3. westerdaled 2013-02-24 at 21:54

    Thanks, I gather I can pass OnSucceedCallback as a delegate. As you say I can also pass anything that will influence the CAML query as parameter to the delegate method. Thanks again for your advice.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...

%d bloggers like this: