Вопрос

I am creating a console app that will create sitepages with certain webparts in it.

To Manage this I am using OfficeDevPnP and how I do it is described in the text below.

The issue here is that the sitepage is created successfully with all my webparts in it except the PowerBi webpart. The Power BI webpart is created and the url Property is set to the url I specefied but I can't see the webpart unless I enter edit mode once again and republish the page.

I am creating the sitepage in the following steps:

  1. Getting context of the SiteCollection that I am targeting
  2. Reading a Json file defining my pages and webparts that is going to be created
  3. Creating a sitePage with
    context.Web.AddClientSidePage(page.SitePageName, false)
  4. Attaching my webparts to the sitepage in the following steps

    1. Getting all components and selecting the Power BI component
      page.AvailableClientSideComponents()
    2. Creating a ClientSideWebPart with the Power BI component
       new ClientSideWebPart(pwerBiComponent)
    3. Adding url to my Power BI report Properties
      JToken jTokenVal = "https://myPowerbiUrl.justatesturl";
      powerBiWebpart.Properties.Add("currentReportEmbedCode", jTokenVal);
    4. Adding webpart to pagecontrol
      page.AddControl(powerBiWebpart);
  5. Saving and publishing the page

      page.Save();
      page.Publish();

So my question here is why isn't the webpart visible until I edit the page?

Это было полезно?

Решение

Because the webpart needs a set a configuration, which you provide during editing the page, rather you should add the webpart to the page with preconfigured set of properties. That will make your webpart appear directly

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top