Pnp-modern-search: Person Refiner - Cannot read property 'toLowerCase' of undefined

Created on 10 Aug 2020  ·  7Comments  ·  Source: microsoft-search/pnp-modern-search

Version used
3.14.2.0

Describe the bug
Refiner/Filter webpart crashes when click to expand Person (using Person template) results.

To Reproduce
Click to expand Person. It started to occur after forcing the library to re-index. Before doing this action, it was working for newly created documents (freshly indexed).

Expected behavior
Expand and show Person template filters to choose.

Screenshots
Console Error Message:
react_devtools_backend.js:2273 TypeError: Cannot read property 'toLowerCase' of undefined
at search-refiners-web-part_ec2cb2a12ad5aa9359f70b494aec5263.js:1
at Array.filter ()
at search-refiners-web-part_ec2cb2a12ad5aa9359f70b494aec5263.js:1
at Array.map ()
at t.render (search-refiners-web-part_ec2cb2a12ad5aa9359f70b494aec5263.js:1)
at oa (sp-pages-assembly_en-ie_997ef04e722fc5f2ed093549634082ff.js:1)
at aa (sp-pages-assembly_en-ie_997ef04e722fc5f2ed093549634082ff.js:1)
at Oo (sp-pages-assembly_en-ie_997ef04e722fc5f2ed093549634082ff.js:1)
at ko (sp-pages-assembly_en-ie_997ef04e722fc5f2ed093549634082ff.js:1)
at bo (sp-pages-assembly_en-ie_997ef04e722fc5f2ed093549634082ff.js:1)

Desktop (please complete the following information):

  • New Edge browser.

Additional context
Using React Dev Tools I could export these data form the component:

{ "webPartTitle": "", "availableRefiners": [ "{FilterName: \"Created\", Values: Array(6)}", { "FilterName": "RefinableString06", "Values": [ { "RefinementCount": 57, "RefinementName": "RefinableString06", "RefinementToken": "\"ǂǂ53617261682e486f67616e404344424176696174696f6e2e6165726f207c20536172616820486f67616e207c2036393341333032333245363637433644363536443632363537323733363836393730374337333638364636373430363336343632363136433636324536333646364420693a30232e667c6d656d626572736869707c73686f6740636462616c662e636f6d\"", "RefinementValue": "[email protected] | asd asd | 693A30232E667C6D656D626572736869707C73686F6740636462616C662E636F6D i:0#.f|membership|[email protected]" }, "{RefinementCount: 41, RefinementName: \"RefinableStr…}", "{RefinementCount: 12, RefinementName: \"RefinableStr…}", "{RefinementCount: 10, RefinementName: \"RefinableStr…}", "{RefinementCount: 7, RefinementName: \"RefinableStri…}", "{RefinementCount: 7, RefinementName: \"RefinableStri…}", "{RefinementCount: 6, RefinementName: \"RefinableStri…}", "{RefinementCount: 5, RefinementName: \"RefinableStri…}", "{RefinementCount: 3, RefinementName: \"RefinableStri…}", "{RefinementCount: 2, RefinementName: \"RefinableStri…}", "{RefinementCount: 1, RefinementName: \"RefinableStri…}", "{RefinementCount: 1, RefinementName: \"RefinableStri…}", "{RefinementCount: 1, RefinementName: \"RefinableStri…}", "{RefinementCount: 1, RefinementName: \"RefinableStri…}", "{RefinementCount: 1, RefinementName: \"RefinableStri…}" ] }, "{FilterName: \"owstaxidmetadataalltagsinfo\", Values:…}", "{FilterName: \"RefinableString05\", Values: Array(12)}", "{FilterName: \"RefinableString00\", Values: Array(13)}", "{FilterName: \"RefinableString01\", Values: Array(10)}" ], "refinersConfiguration": [ "{displayValue: \"Created Date\", refinerName: \"Create…}", "{displayValue: \"Person\", refinerName: \"RefinableStr…}", "{displayValue: \"Tags\", refinerName: \"owstaxidmetada…}", "{displayValue: \"Document Type\", refinerName: \"Refin…}", "{displayValue: \"Lessee\", refinerName: \"RefinableStr…}", "{displayValue: \"MSN\", refinerName: \"RefinableString…}" ], "showBlank": false, "displayMode": 1, "onUpdateFilters": "ƒ onUpdateFilters() {}", "selectedLayout": 1, "language": "en-US", "query": "{searchTerms}Title,Path,Created,Filename,SiteLogo,PreviewUrl,PictureThumbnailURL,ServerRedirectedPreviewURL,ServerRedirectedURL,HitHighlightedSummary,FileType,contentclass,ServerRedirectedEmbedURL,ParentLink,DefaultEncodingURL,owstaxidmetadataalltagsinfo,Author,AuthorOWSUSER,SPSiteUrl,SiteTitle,IsContainer,IsListItem,HtmlFileType,SiteId,WebId,UniqueID,OriginalPath,FileExtension,IsDocument,NormSiteID,NormWebID,NormListID,NormUniqueID12f2fc9e-b72e-42e4-9227-3ba21902494b", "themeVariant": { "palette": "{accent: \"#03787c\", black: \"#000000\", blackTransluc…}", "fonts": "{large: {…}, medium: {…}, mediumPlus: {…}, mega: {……}", "semanticColors": "{accentButtonBackground: \"#03787c\", accentButtonTex…}", "isInverted": false, "disableGlobalClassNames": false, "spacing": "{l1: \"20px\", l2: \"32px\", m: \"16px\", s1: \"8px\", s2: …}", "effects": "{elevation16: \"0 6.4px 14.4px 0 rgba(0, 0, 0, 0.132…}" }, "userService": { "_pageContext": "{_aadInfo: {…}, _cultureInfo: {…}, _getPropertyValu…}", "_localPnPSetup": "{_baseUrl: \"https://asdasd.sharepoint.com/sites/asdasdas…}", "getUserInfos": "ƒ () {}" }, "defaultSelectedRefinementFilters": [] }

All 7 comments

Can you share something about what the values of the managed property you are using are looking like? Are there different format? And I assume you followed the guide at https://microsoft-search.github.io/pnp-modern-search/search-parts/search-filters/#persona when setting it up :)

Sure thing! Which values do you want me to share with you?

And yes, I followed the link above to configure the Person template. But to be honest I didn't understand if I have to configure additional fields.

I just configured the RefinableString06 managed property to map ows_q_USER_Author. Do I need to add more mapped Crawled properties?

image

@thiagottss what does the value in an item which causes the error look like? The value of ows_q_USER_Author for a failing item.

hey @wobba ... I've got some spare time today and run a debug session...

image

Probably this is the issue. I didn't go deep why it is returning undefined but my suspicion is because this user is disabled on our environment.

These are the changes I applied to get it fixed locally:
image

@thiagottss care to do a PR with that change? :)

Is there a guide on how to create a PR for this repo? I tried the usual but I got an access denied when trying to push my branch... should I use one of the existing branches?

No special guide..same as other github.

  • Fork repro
  • Create fix branch of the development branch in your fork
  • Do changes and publish branch
  • Go to your github and create PR off that branch and target our develop branch

https://opensource.com/article/19/7/create-pull-request-github

Was this page helpful?
0 / 5 - 0 ratings