Cannot get related items with PnPjs search on workflow task content type

Milind Saraswala 1 Reputation point

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
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 })

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
1,616 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,378 questions
No comments
{count} votes

1 answer

Sort by: Oldest
  1. Baker Kong-MSFT 3,781 Reputation points

    Hi @Milind Saraswala ,

    I am able to reproduce this issue here, the 'RelatedItems' property always returns null.


    Based on below docs, SelectProperties must be managed properties and their retrievable flag should be true.


    'RelatedItems' has not been crawled, so we need to map it to a managed property.




    Note: Please make sure the task really has related items and it may cost some time for crawling.

    Best Regards,
    Baker Kong

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.