SharePoint JavaScript Object Model

MSDN Hauptartikel

Beispielcode:

$(document).ready(function () {
    ExecuteOrDelayUntilScriptLoaded(onPageLoaded, "sp.js");
    SP.SOD.executeFunc("sp.js", null, onPageLoaded);
});

function onPageLoaded() {
    getEnvironment();
}

function getEnvironment() {
    context = SP.ClientContext.get_current();

    currentUser = context.get_web().get_currentUser();
    context.load(currentUser);
    context.executeQueryAsync(onQueryUserSucceeded, onQueryFailed);
}

function onQueryUserSucceeded(sender, args) {
    onUserLoaded();
}

function onQueryFailed(sender, args) {
    alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}

function onUserLoaded() {
    if (isSiteOwner()) {
        // this is the site owner, load profile properties
        //ExecuteOrDelayUntilScriptLoaded(onUserProfilePropertiesLoaded, "userprofile");
        SP.SOD.executeFunc("userprofile", null, onUserProfilePropertiesLoaded);
    }
}

function onUserProfilePropertiesLoaded() {
    var peopleManager = SP.UserProfiles.PeopleManager(context);
    personProperties = peopleManager.getPropertiesFor(currentUser);

    context.load(personProperties);
    context.executeQueryAsync(onQueryProfileSucceeded, onQueryFailed);
}

function onQueryProfileSucceeded(sender, args) {
    userPolicyExceptDate = personProperties.get_userProfileProperties()['PersonalDisclaimer'];

    if (userPolicyExceptDate !== null) {
        // ok we got the date, load the last modified date from the document
        loadDocumentLastModified
    } else {
        // date not set, show user policy dialog
        ExecuteOrDelayUntilScriptLoaded(onDialogReady, "sp.ui.dialog.js");
    }
}

function loadDocumentLastModified() {
    var clientContext = new SP.ClientContext(documentWebUrl);
    var oList = clientContext.get_web().get_lists()[documentList];

}

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × 4 =