I am working on SPFx Project and using PnPjs search. My requirement is to search for pending workflow task for that I have created result source at site collection level. Builder query as below
{searchTerms} ContentTypeId:0x0108* Path:{SiteCollection.URL} WorkflowOutcomeOWSTEXT:Pending
Now I am using SPFx to retrieve data. I cannot get related item of the task or related item id for the original item. Other than that I get all data. Let me know I am doing wrong or there is some issue pnpjs
My code as below (SPFx v2.0.6 and SharePoint Online/2019)
const getContentTypeData = async (rowLimit: number, sourceId: string, querytext: string, selectedProperties: string[]) => {
const appSearchSettings: ISearchQuery = {
RowLimit: rowLimit,
EnableInterleaving: true,
SourceId: sourceId,
TrimDuplicates: false,
Querytext: querytext,
SelectProperties: selectedProperties
}
const searchResults: SearchResults = await sp.search(appSearchSettings)
return searchResults
}
const selectedProperties = ['ListItemID', 'Path', 'Title', 'HitHighlightedSummary', 'LastModifiedTime', 'ParentLink', 'RelatedItems']
const rowLimit = 10
let queryText = AssignedTo:"${displayName}"
// Passing current user displayName
getContentTypeData(rowLimit, searchSourceId.PendingTask, queryText, selectedProperties)
.then((r: SearchResults) => {
setPendingTask({ totalRows: r.TotalRows, primarySearchResults: r.PrimarySearchResults })
})
.catch(console.warn)