0

I'm using pnp.sp.serach to search files and folders.

I need to search by file's and folder's date.

I see results have properties LastModifiedTime, but the value came undefined.

 pnp.sp.search({
                Querytext: query,
                RowLimit: 20,
                StartRow: 0,
                SelectProperties: ["Title", "Author", "Path", "FileType", "RefinersTextListOWSTEXT"]
            })

                .then((results) => {
                    results.PrimarySearchResults.forEach((result) => {
                        _results.push({
                            title: result.Title,
                            description: result.HitHighlightedSummary,
                            link: result.Path,
                            author: result.Author,
                            filetype: result.FileType,
                            path: result.OriginalPath,
                            date: result.LastModifiedTime
                        });
                    });
                })
                .then(
                    () => { resolve(_results); }
                )
                .catch(
                    () => { reject(new Error("Error")); }
                );
5
  • Did you try to add LastModifiedTime into selected properties? Jan 11 at 4:59
  • @KalpeshVaghela Yes, I tried, it came undefined
    – Ann
    Jan 11 at 6:54
  • Can you try using this managed property: ModifiedOWSDATE? Let me know if it works for you! Jan 11 at 9:30
  • 1
    @GaneshSanap yes, it is work! I made like this SelectProperties: ["Title", "Author", "Path", "FileType", "RefinersTextListOWSTEXT","ModifiedOWSDATE"]
    – Ann
    Jan 11 at 11:26
  • Great, glad it worked for you! Jan 11 at 11:31

1 Answer 1

1

Use managed property named ModifiedOWSDATE instead of LastModifiedTime.

It will give you the modified date in search results. Use SelectProperties like:

SelectProperties: ["Title", "Author", "Path", "FileType", "RefinersTextListOWSTEXT", "ModifiedOWSDATE"]

And then you can get the value in success callback using:

date: result.ModifiedOWSDATE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.