I have a task where I need to Set the New Page Default Settings as you do at "/_layouts/15/AreaTemplateSettings.aspx" but I need to do this via JSOM. Does anyone know how to do this?

The New Page Default Settings specify the default page layout and page URL to use when creating a new page.

I have looked through all of SP.Publishing.js and I don't think it's possible as there isn't a method that allows you to retrieve this value, never mind set it. (I could be wrong though as JS isn't great).

If JSOM no good, perhaps it can be done using REST?

1 Answer 1


It appears that the DefaultPageLayout is stored in the Web Property bag in the format

<layout guid="[UniqueId]" url="_catalogs/masterPage/mypageLayout.aspx"/>

The way I solved this problem is using JavaScript below.

var context;
var list;
var properties;
var pageLayoutPage = "MyPageLayout.aspx";

  function changePageLayoutDefault(){
    context = SP.ClientContext.get_current();
    properties = context.get_web().get_allProperties ( );
    list = context.get_web().get_lists().getByTitle('Master Page Gallery');
    var camlQuery = new SP.CamlQuery();
    var query = "<View><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>" + pageLayoutPage + "</Value></Eq></Where></Query><RowLimit>10</RowLimit></View>";
    this.collListItem = list.getItems(camlQuery);

context.load(collListItem, 'Include(FileLeafRef,UniqueId)');

context.executeQueryAsync( function (){
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();

        var oListItem = listItemEnumerator.get_current();
        if(oListItem.get_item('FileLeafRef') == pageLayoutPage){
         var configStr = '<layout guid="' + oListItem.get_item('UniqueId') + '" url="_catalogs/masterpage/' + oListItem.get_item('FileLeafRef') + '" />';

         properties.set_item("__DefaultPageLayout", configStr);
         context.get_web( ).update();
         context.executeQueryAsync(function ( ) {alert('updated');},function ( ) {alert('error dude!');} );
        alert('should not get hit');
}, function() {alert('error')});        

   SP.SOD.executeOrDelayUntilScriptLoaded ( function () { changePageLayoutDefault();}, "sp.js"); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.