Share via


SP.WebParts.LimitedWebPartManager.importWebPart Method (sp.js)

Imports a Web Part from a string in the .dwp format.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

SP.WebParts.LimitedWebPartManager.importWebPart(webPartXml)

Parameters

  • webPartXml
    Type: String

    The Web Part markup to import.

Return value

Returns a SP.WebParts.WebPartDefinition instance representing the Web Part markup to import.

Exceptions

Exceptions

Exception Type

Condition

WebPartPageUserException

The provided Web Part markup is not in the .dwp or .webpart format. Error code: -1

UnauthorizedAccessException

The current user has insufficient permissions. Error code: -2147024891

Remarks

After importing, the Web Part is not added to a Web Part Page. To add a Web Part to a Web Part Page, use addWebPart, supplying the object returned by this method.

When Scope is User, the current user must have permissions to add and delete personalized Web Parts. When Scope is Shared, the current user must have permissions to customize pages.

It must not be null. It must not be empty. It must be valid XML in the .dwp or .webpart format.