If somebody like the post and its helpful in your work then, add comments.

Monday, March 2, 2015

Office 365 : Create a site using custom site template

To create a site using your designed custom site template in JSOM/ECMA, we can use below example :

 createProjectSite = function ($data) {
            dialogValue = SP.UI.ModalDialog.showWaitScreenWithNoClose("Site Creation", "Working on it...", 120, 400);
            id($data.Id);
            var url = $data.Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
            currentProjectObject = $data;
            var clientContext = CORO.megaMenucontext;
   


            var WCI = new SP.WebCreationInformation();
            WCI.set_webTemplate('{a5269682-aec6-49d7-b3f5-7481039abff8}#ProjectTemplate');
            WCI.set_description($data.ProjectDescription);
            WCI.set_title($data.Title);
            WCI.set_url(url);
            WCI.set_language('1033');
            if ($data.Access == "Public") { WCI.set_useSamePermissionsAsParentSite(true); }//To inherit the permission
            if ($data.Access == "Closed") { WCI.set_useSamePermissionsAsParentSite(false); }//To break the permission
            newWeb = projectWeb.get_webs().add(WCI);
            //save changes and generate callbacks
            clientContext.load(projectWeb);
            clientContext.executeQueryAsync(onCreationSuccess, onQueryFailed);
        },

Office 365 : How to update quick launch node in SharePoint 2013

To update a navigation note in SharePoint quick lanuch, we can do by JSOM. In below example we are updating the red box node.
        collChildNavNode =null,
        getNavigationNode = function(web, listData)
        {
             var clientContext = CORO.megaMenucontext;
            // Get the Quick Launch navigation node collection.
            quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();
            clientContext.load(quickLaunchNodeCollection);
            clientContext.executeQueryAsync(getNavigationNodeSuccess,onQueryFailed);
        },
        getNavigationNodeSuccess = function (sender, args) {
            var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
            var clientContext = CORO.megaMenucontext;
            collChildNavNode = quickLaunchNodeCollection.get_item(0);     
            clientContext.load(collChildNavNode);
            clientContext.executeQueryAsync(createNavNode ,onQueryFailed);
        },
        createNavNode = function()
        {
            var url = currentProjectObject .Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
            var clientContext = CORO.megaMenucontext;
            collChildNavNode.set_title('Home');
            collChildNavNode.set_url("/sites/dk/sites/projects/" +url);       
            collChildNavNode.update();    
            clientContext.executeQueryAsync(createNavNodeSuccess, onQueryFailed);
        },
        createNavNodeSuccess = function()
        {
            console.log("Created navigation node");
        },