Guest User

Untitled

a guest
Mar 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var ctxOBJ = SP.ClientContext.get_current();
  2. var webOBJ = ctxOBJ.get_web();
  3. var siteOBJ = ctxOBJ.get_site();
  4. var pageURL = window.location.pathname;
  5. var webPartManagerOBJ = webOBJ.getFileByServerRelativeUrl(pageURL).getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
  6. //get the web parts on the current page
  7. var collWebPart = webPartManagerOBJ.get_webParts();
  8. //request the web part collection and load it from the server
  9. ctxOBJ.load(collWebPart);
  10. ctxOBJ.executeQueryAsync(Function.createDelegate(this, function() {
  11. // Go through all webparts
  12. for (var x = 0; x < collWebPart.get_count(); x++) {
  13. debugger;
  14. var webPartDef = collWebPart.get_item(x);
  15. console.log(webPartDef.get_id().toString());
  16. }
  17. }), Function.createDelegate(this, function() {
  18. alert("failed to fetch shared webparts from page")
  19. }));
Add Comment
Please, Sign In to add comment