Open OliverZeiser opened 6 years ago
You can set it via the jsonproperties...that's at least how I do it and how the provisioning engine does it. Would that work for you?
I did not test it yet and this might work, but that would be very inconsistent. When reading the WebPart from the page via PnP Core the JsonProperties does not contain the ServerProcessedContent. So when modifying the WebPart settings via code you would have to read from ServerProcessedContent and write that back to JsonProperties again. It would make much more sense setting properties via Properties and ServerProcessedContent via ServerProcessedContent. But maybe I am doing something wrong or I am not understanding this correctly...
So i think best would be something like this (and same for reading of course):
wp.ServerProcessedContent.searchablePlainTexts["title"] = "My Title";
wp.Properties["selectedListId"] = "someguid";
Okay, I did some further testing and it does indeed work when setting it via JsonProperties. BUT when I read the webpart from the page again via code, the ServerProcessedContent is NULL. When I manually edit the webpart on the page, save it and read it again, I have a value in ServerProcessedContent. I did not figure out where the issue occures, but I am guessing there is a bug when writing the html back to the page. It looks like the ServerProcessedContent is not part of the "data-sp-webpartdata". I think I need to create a debug version if I can find the time for it and digg into it a little deeper. But maybe you can have a look at this as well...
@OliverZeiser Hi, I'm just also encountering the same issue. When creating the webpart & setting propertiesJSON it works fine, but when executing the code again, server processed content will be NULL. When removing/adding a link in the UI and saving/publushing it, server processed content will again be filled properly.
At the end of my code I have a .Save() and .Publish(), maybe this is "faulty" and doesn't properly write the serverprocessedcontent to the webpart? Or it isn't properly set when reassigning it again in propertiesJSON... it's really annoying because I have a need to refresh the webpart and add quicklinks based on other sites made, so when adding one via code, serverprocessedcontent is NULL and I need to get the existing links & titles...
I hope they'll fix or take a look at it soon.
Hi I have the same issue. Is there another way to set the title, the jsonproperties does not work. It takes the value from the ServerProcessedContent.
Hi @OliverZeiser
If it still open, here is the solution:
PropertiesJson = "{\"webPartData\":{\"serverProcessedContent\":{\"searchablePlainTexts\": {\"title\": \"Events\" }}}}"
Yes, it does work that way, but as I mentioned before, that is not consistent when updating an existing WebPart.
Category
[X] Bug [X] Enhancement
Environment
[X] Office 365 / SharePoint Online
Expected or Desired Behavior
We should be able to set the ServerProcessedContent property for ClientSideWebPart. For some webparts like the OOTB Events Webpart this is a must if we want to programatically add the Webpart with a title.
Observed Behavior
Currently we can only provision the Webpart without the title because this is part of the ServerProcessedContent and not the Properties.
Steps to Reproduce
Add the Events Webpart to a modern page programatically and try to give it a title via Code...