C# how to configure SPFx webpart searchable properties #449
-
I am adding a webpart like this : var component = page.AvailablePageComponents().FirstOrDefault(c => new Guid(c.Id) == new Guid("GUID"));
if (component != null)
{
var webpart = page.NewWebPart(component);
AccordionProperties properties = new ()
{
Description = "Accordion",
AccordionItems = items,
};
webpart.PropertiesJson = JsonSerializer.Serialize(properties, new JsonSerializerOptions()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
});
page.AddControl(webpart, page.Sections[0].Columns[0]);
} The SPFx webpart set the properties as searchable with the following configuration : protected get propertiesMetadata(): IWebPartPropertiesMetadata {
return {
'accordionItems[*].header': { isSearchablePlainText: true },
'accordionItems[*].content': { isSearchablePlainText: true },
}
} My problem is the following, on the webpart, we can't set webpart.ServerProcessedContent by code and it seems not automatically done during the process. So the webpart in the page looks like this : If I search the text within my webpart in the search at this moment, no result is found. But if I click on the edit button on the modern page and save it directly... then the properties is empty, but the serverProcessedContent contains my items and it is now searchable. Then if I am searching for the webpart text content, result start appearing in the search. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Asnwered in #451 |
Beta Was this translation helpful? Give feedback.
Asnwered in #451