I'm planning to get zone information of a web part using JSOM and I couldn't find any chance of getting it.

My Code:

var ctxOBJ = SP.ClientContext.get_current();
var webOBJ = ctxOBJ.get_web();
var siteOBJ = ctxOBJ.get_site();
var pageURL = window.location.pathname;
var webPartManagerOBJ = webOBJ.getFileByServerRelativeUrl(pageURL).getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
  //get the web parts on the current page
  var collWebPart = webPartManagerOBJ.get_webParts();
  //request the web part collection and load it from the server
  ctxOBJ.executeQueryAsync(Function.createDelegate(this, function() {
    // Go through all webparts
    for (var x = 0; x < collWebPart.get_count(); x++) {
      var webPartDef = collWebPart.get_item(x);
  }), Function.createDelegate(this, function() {
    alert("failed to fetch shared webparts from page")

I need the zone id of each web part in that page.
Can anyone help me on this?

1 Answer 1


For ZoneId you'll have to use get_zoneId().

Change the load:


And the use get_zoneId():


If you plan to use props on the webpart itself, you'll have to load that too:

ctxOBJ.load(collWebPart,  'Include(WebPart.Title,WebPart.ZoneIndex, ZoneId)');

And then:

  • Can I get the property of webpart whether hidden or not?
    – RealSteel
    Mar 23, 2018 at 7:42
  • 2
    @RealSteel you are probably thinking about if its closed or not? Then you have webPartDef.get_webPart().get_isClosed(), remember to add the prop to the load: 'Include(WebPart.IsClosed,WebPart.Title,WebPart.ZoneIndex, ZoneId)' Mar 23, 2018 at 7:57

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.