3

I need to get the ID of a web part on a page before I have redirected the browser to the page.

The reason for this is that I need to update a field value that contains web part settings, which are linked via the web part ID's. I can access the page field and update it through a POST-call using the REST API, but I have yet to find a way to retrieve the web part ID's on the page.

If the case was that I could load the page first, then it would have been simple to retrieve them with jQuery.

Is this possible, or do I have to find another way? Using CSOM would be an acceptable answer as long as it's done with JavaScript.

6

You can get the ID through GetLimitedWebPartManager method

You need file URL, the scope and something to filter by. Here is an example:

_api/Web/GetFileByServerRelativeUrl('/sites/test/Home.aspx')/GetLimitedWebPartManager(scope=1)/WebParts?$expand=WebPart&$filter=WebPart/Title+eq+'Test'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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