0

As the title states I am trying to use the PropertyFieldCollectionData in my SPFx Property Pane. But when I run the code and try to search in the peoplepicker nothing shows up, not even myself.

Don't know if it would be of any help but here is the imports as well

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
  IPropertyPaneConfiguration,
  IPropertyPaneDropdownOption,
  PropertyPaneTextField
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart, WebPartContext } from '@microsoft/sp-webpart-base';
import * as strings from 'FaqProjectWebPartStrings';
import FaqProject from './components/FaqProject';
import { IFaqProjectProps } from './components/FaqProject';
import { PropertyFieldListPicker, PropertyFieldListPickerOrderBy } from '@pnp/spfx-property-controls/lib/PropertyFieldListPicker';
import { IPropertyFieldGroupOrPerson, PropertyFieldDropdownWithCallout, PropertyFieldPeoplePicker } from '@pnp/spfx-property-controls';
import { CalloutTriggers } from '@pnp/spfx-property-controls/lib/PropertyFieldHeader';
import { PropertyFieldToggleWithCallout } from '@pnp/spfx-property-controls/lib/PropertyFieldToggleWithCallout';
import { PropertyFieldCollectionData, CustomCollectionFieldType } from '@pnp/spfx-property-controls/lib/PropertyFieldCollectionData';   
import { PeoplePicker, PrincipalType } from '@pnp/spfx-controls-react/lib/PeoplePicker';

Sample code in my FaqProjectWebPart.ts

                PropertyFieldCollectionData("collectionData", {
                  key: "collectionData",
                  label: "Collection data",
                  panelHeader: "Collection data panel header",
                  manageBtnLabel: "Manage collection data",
                  value: this.properties.collectionData,
                  fields: [
                    {
                      id: "Title",
                      title: "Name",
                      type: CustomCollectionFieldType.string,
                      required: true
                    },
                    {
                      id: "Group",
                      title: "Choose a group",
                      type: CustomCollectionFieldType.custom,
                      onCustomRender: (field, value, onUpdate, item, itemId, onError) => {
                        return (
                          React.createElement(PeoplePicker, {
                            context: this.context as any ,
                            personSelectionLimit: 1,
                            showtooltip: true,
                            key: itemId,
                            defaultSelectedUsers: [item.customFieldId],
                            onChange: (items: any[]) => {
                              console.log("Items", items);
                              item.customFieldId = items[0].secondaryText;
                              onUpdate(field.id, items[0].secondaryText);
                            },
                            showHiddenInUI: false,
                            principalTypes: [PrincipalType.User]
                          })
                        )
                      },
                    },
                  ],
                  disabled: false
                }),

Props

export interface IFaqProjectWebPartProps {
  description: string;
  faqListId: string;
  categoryListId: string;
  subCategoryListId: string;
  panelViewToggle: boolean;
  people: IPropertyFieldGroupOrPerson[];
  collectionData: any[];  
}
  • I'd clicked F12and checked the error log (console) – Nikolay Sep 28 '22 at 21:12
  • Yes of course that would be great but the thing is that there are no errors showing up in the console. Though after further investigation I got an error under network. The error has en error 400 and gives the following error: {code: "-1, Microsoft.OData.Core.ODataException",…}} error: {code: "-1, Microsoft.OData.Core.ODataException",…} code: "-1, Microsoft.OData.Core.ODataException" message: "A null value was found for the property named 'SharePointGroupID', which has the expected type 'Edm.Int32[Nullable=False]'. The expected type 'Edm.Int32[Nullable=False]' does not allow null values." – liondepierre Sep 29 '22 at 07:26
  • Looks like this bug: https://github.com/pnp/sp-dev-fx-controls-react/issues/1292 I would try the previous version of spfx controls library – Nikolay Sep 29 '22 at 07:51
  • Thank you, I changed the version to 3.9 and it now seems to be working – liondepierre Sep 29 '22 at 09:39
  • I'll post that as an answer then – Nikolay Sep 29 '22 at 10:30

1 Answers1

2

There appears to be a bug in version 3.10 of the spfx-controls-react library (to be fixed in 3.11) that is causing this behavior. For the workaround it's possible to rollback to 3.9

https://github.com/pnp/sp-dev-fx-controls-react/issues/1292

Nikolay
  • 10,752
  • 2
  • 23
  • 51