Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.load(collWebPart);
- ctxOBJ.executeQueryAsync(Function.createDelegate(this, function() {
- // Go through all webparts
- for (var x = 0; x < collWebPart.get_count(); x++) {
- debugger;
- var webPartDef = collWebPart.get_item(x);
- console.log(webPartDef.get_id().toString());
- }
- }), Function.createDelegate(this, function() {
- alert("failed to fetch shared webparts from page")
- }));
Add Comment
Please, Sign In to add comment