I'm struggling making web parts with lists on it searchable using SPFx.
My static react cards are working just fine based on this solution: How to make SPFx web part content searchable
But then for lists is different. I tried adding the list elements onInit
, and I can make them searchable, but then if the list changes the CanvasContent1
field will not change so the crawler will not pick the changes on that page's content.
Is it possible to sync the CanvasContent1
content which the actual content list?.
This is my current onInit()
block:
public async onInit(): Promise<void> {
this._environmentMessage = await this._getEnvironmentMessage();
this._sp = getSP(this.context);
const spCache = spfi(this._sp).using(Caching({ store: "session" }));
const response: IResponseItem[] = await spCache.web.lists
.getByTitle("React List")
.items.select("Id", "Title", "FileLeafRef", "CustomField")
.expand()();
const items: IFile[] = response.map((item: IResponseItem) => {
return {
Id: item.Id,
Title: item.Title || "Unknown",
CustomField: item.CustomField || "Unknown",
Name: item.FileLeafRef,
};
});
this.properties.list = items;
this.properties.searchableList = "React List:" + items.map((item: IFile) => item.Title).join(", ");
await super.onInit();
}
If I try adding a regular SharePoint list to a page, I can only see the list title.