Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Form] Update Form crashes on loading, if an item has TaxonomyFieldTypeMulti field. [3.16.1] !!! #1733

Closed
bva999 opened this issue Jan 9, 2024 · 21 comments · Fixed by #1757
Labels
status:fixed Issue fixed in current or prior release. type:bug
Milestone

Comments

@bva999
Copy link

bva999 commented Jan 9, 2024

Category

[ ] Enhancement

[x ] Bug

[ ] Question

Version

Please specify what version of the library you are using: [3.16.1]

Observed Behavior

If an item has a TaxonomyFieldTypeMulti field , the Dynamic Form crashes on loading. And get next error:

`Error get field informations TypeError: defaultValue.split is not a function
    at eval (DynamicForm.js:591:1)
    at step (DynamicForm.js:58:1)
    at Object.eval [as next] (DynamicForm.js:39:45)
    at step (DynamicForm.js:43:1)
    at Object.eval [as next] (DynamicForm.js:39:45)
    at fulfilled (DynamicForm.js:30:42)`

It assumes that value should be a string , but it is an Array of objects:

Screenshot 2024-01-09 135139

@ghost
Copy link

ghost commented Jan 9, 2024

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@michaelmaillot
Copy link
Collaborator

michaelmaillot commented Jan 9, 2024

Hi @bva999,

I tried to repro without success but maybe I'm missing context info.

Can you give me details about the Taxonomy field you're refering to, such as column settings, term structure (parent / children),...?

In my case I tried with following config (sorry it's in french):

image

image

image

Edit: this is the content of my defaultValue

image

@bva999
Copy link
Author

bva999 commented Jan 10, 2024

Hi @michaelmaillot .
Here is my field object from debugger:

`{
    "@odata.editLink": "Web/Lists(guid'***')/Fields(guid'***')",
    "@odata.id": "https://***/_api/Web/Lists(guid'***')/Fields(guid'***')",
    "@odata.type": "#SP.Taxonomy.TaxonomyField",
    "AllowMultipleValues": true,
    "AnchorId": "00000000-0000-0000-0000-000000000000",
    "AutoIndexed": false,
    "CanBeDeleted": true,
    "ClientSideComponentId": "00000000-0000-0000-0000-000000000000",
    "ClientSideComponentProperties": null,
    "ClientValidationFormula": null,
    "ClientValidationMessage": null,
    "CreateValuesInEditForm": false,
    "CustomFormatter": null,
    "DefaultFormula": null,
    "DefaultValue": "",
    "DependentLookupInternalNames": [
    ],
    "Description": "",
    "Direction": "none",
    "EnforceUniqueValues": false,
    "EntityPropertyName": "Sectors",
    "FieldTypeKind": 0,
    "Filterable": true,
    "FromBaseType": false,
    "Group": "PMCG",
    "Hidden": false,
    "Id": "f848fa73-04f7-44bb-95f2-1fb32df1211c",
    "Indexed": false,
    "IndexStatus": 0,
    "InternalName": "Sectors",
    "IsAnchorValid": true,
    "IsDependentLookup": false,
    "IsDocTagsEnabled": false,
    "IsEnhancedImageTaggingEnabled": false,
    "IsKeyword": false,
    "IsModern": false,
    "IsPathRendered": true,
    "IsRelationship": true,
    "IsTermSetValid": true,
    "JSLink": "SP.UI.Taxonomy.js|SP.UI.Rte.js(d)|SP.Taxonomy.js(d)|ScriptForWebTaggingUI.js(d)",
    "LookupField": "Path$Resources:core,Language;",
    "LookupList": "{02461283-ca3f-417b-bbc7-9bedce50e969}",
    "LookupWebId": "5bd3f994-09e3-4405-9d01-36fb23af4515",
    "Open": false,
    "order": 6,
    "PinnedToFiltersPane": false,
    "PrimaryFieldId": null,
    "ReadOnlyField": false,
    "RelationshipDeleteBehavior": 0,
    "Required": false,
    "SchemaXml": "<Field Type=\"TaxonomyFieldTypeMulti\" DisplayName=\"Sectors\" List=\"{02461283-ca3f-417b-bbc7-9bedce50e969}\" WebId=\"5bd3f994-09e3-4405-9d01-36fb23af4515\" ShowField=\"Path1033\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Mult=\"TRUE\" Sortable=\"FALSE\" Group=\"PMCG\" ID=\"{f848fa73-04f7-44bb-95f2-1fb32df1211c}\" SourceID=\"{5bd3f994-09e3-4405-9d01-36fb23af4515}\" StaticName=\"Sectors\" Name=\"Sectors\" AllowDeletion=\"TRUE\" Version=\"48\" ColName=\"int2\" RowOrdinal=\"0\"><Default /><Customization><ArrayOfProperty><Property><Name>SspId</Name><Value xmlns:q1=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q1:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">5e76d934-89d8-476d-a29f-379cd1d37584</Value></Property><Property><Name>GroupId</Name></Property><Property><Name>TermSetId</Name><Value xmlns:q2=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q2:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">c6c7e0c1-3e32-4f8f-9c31-d4b6b0582a9e</Value></Property><Property><Name>AnchorId</Name><Value xmlns:q3=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q3:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">00000000-0000-0000-0000-000000000000</Value></Property><Property><Name>UserCreated</Name><Value xmlns:q4=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q4:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>Open</Name><Value xmlns:q5=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q5:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>TextField</Name><Value xmlns:q6=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q6:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">{46f582c6-b2a5-4035-9ae6-dff9e4ab8ee2}</Value></Property><Property><Name>IsPathRendered</Name><Value xmlns:q7=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q7:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">true</Value></Property><Property><Name>IsKeyword</Name><Value xmlns:q8=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q8:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>TargetTemplate</Name></Property><Property><Name>CreateValuesInEditForm</Name><Value xmlns:q9=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q9:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>FilterAssemblyStrongName</Name><Value xmlns:q10=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q10:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">Microsoft.SharePoint.Taxonomy, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Value></Property><Property><Name>FilterClassName</Name><Value xmlns:q11=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q11:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">Microsoft.SharePoint.Taxonomy.TaxonomyField</Value></Property><Property><Name>FilterMethodName</Name><Value xmlns:q12=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q12:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">GetFilteringHtml</Value></Property><Property><Name>FilterJavascriptProperty</Name><Value xmlns:q13=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q13:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">FilteringJavascript</Value></Property></ArrayOfProperty></Customization></Field>",
    "Scope": "/sites/development/Lists/Partners",
    "Sealed": false,
    "ShowInFiltersPane": 0,
    "Sortable": false,
    "SspId": "5e76d934-89d8-476d-a29f-379cd1d37584",
    "StaticName": "Sectors",
    "TargetTemplate": null,
    "TermSetId": "c6c7e0c1-3e32-4f8f-9c31-d4b6b0582a9e",
    "TextField": "46f582c6-b2a5-4035-9ae6-dff9e4ab8ee2",
    "Title": "Sectors",
    "TypeAsString": "TaxonomyFieldTypeMulti",
    "TypeDisplayName": "Managed Metadata",
    "TypeShortDescription": "Managed Metadata",
    "UnlimitedLengthInDocumentLibrary": false,
    "UserCreated": false,
    "ValidationFormula": null,
    "ValidationMessage": null
}`
{
    "@odata.editLink": "Web/Lists(guid'***')/Fields(guid'***')",
    "@odata.id": "https://***/_api/Web/Lists(guid'***')/Fields(guid'***')",
    "@odata.type": "#SP.Taxonomy.TaxonomyField",
    "AllowMultipleValues": true,
    "AnchorId": "00000000-0000-0000-0000-000000000000",
    "AutoIndexed": false,
    "CanBeDeleted": true,
    "ClientSideComponentId": "00000000-0000-0000-0000-000000000000",
    "ClientSideComponentProperties": null,
    "ClientValidationFormula": null,
    "ClientValidationMessage": null,
    "CreateValuesInEditForm": false,
    "CustomFormatter": null,
    "DefaultFormula": null,
    "DefaultValue": "",
    "DependentLookupInternalNames": [
    ],
    "Description": "",
    "Direction": "none",
    "EnforceUniqueValues": false,
    "EntityPropertyName": "Sectors",
    "FieldTypeKind": 0,
    "Filterable": true,
    "FromBaseType": false,
    "Group": "PMCG",
    "Hidden": false,
    "Id": "f848fa73-04f7-44bb-95f2-1fb32df1211c",
    "Indexed": false,
    "IndexStatus": 0,
    "InternalName": "Sectors",
    "IsAnchorValid": true,
    "IsDependentLookup": false,
    "IsDocTagsEnabled": false,
    "IsEnhancedImageTaggingEnabled": false,
    "IsKeyword": false,
    "IsModern": false,
    "IsPathRendered": true,
    "IsRelationship": true,
    "IsTermSetValid": true,
    "JSLink": "SP.UI.Taxonomy.js|SP.UI.Rte.js(d)|SP.Taxonomy.js(d)|ScriptForWebTaggingUI.js(d)",
    "LookupField": "Path$Resources:core,Language;",
    "LookupList": "{02461283-ca3f-417b-bbc7-9bedce50e969}",
    "LookupWebId": "5bd3f994-09e3-4405-9d01-36fb23af4515",
    "Open": false,
    "order": 6,
    "PinnedToFiltersPane": false,
    "PrimaryFieldId": null,
    "ReadOnlyField": false,
    "RelationshipDeleteBehavior": 0,
    "Required": false,
    "SchemaXml": "<Field Type=\"TaxonomyFieldTypeMulti\" DisplayName=\"Sectors\" List=\"{02461283-ca3f-417b-bbc7-9bedce50e969}\" WebId=\"5bd3f994-09e3-4405-9d01-36fb23af4515\" ShowField=\"Path1033\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Mult=\"TRUE\" Sortable=\"FALSE\" Group=\"PMCG\" ID=\"{f848fa73-04f7-44bb-95f2-1fb32df1211c}\" SourceID=\"{5bd3f994-09e3-4405-9d01-36fb23af4515}\" StaticName=\"Sectors\" Name=\"Sectors\" AllowDeletion=\"TRUE\" Version=\"48\" ColName=\"int2\" RowOrdinal=\"0\"><Default /><Customization><ArrayOfProperty><Property><Name>SspId</Name><Value xmlns:q1=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q1:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">5e76d934-89d8-476d-a29f-379cd1d37584</Value></Property><Property><Name>GroupId</Name></Property><Property><Name>TermSetId</Name><Value xmlns:q2=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q2:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">c6c7e0c1-3e32-4f8f-9c31-d4b6b0582a9e</Value></Property><Property><Name>AnchorId</Name><Value xmlns:q3=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q3:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">00000000-0000-0000-0000-000000000000</Value></Property><Property><Name>UserCreated</Name><Value xmlns:q4=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q4:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>Open</Name><Value xmlns:q5=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q5:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>TextField</Name><Value xmlns:q6=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q6:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">{46f582c6-b2a5-4035-9ae6-dff9e4ab8ee2}</Value></Property><Property><Name>IsPathRendered</Name><Value xmlns:q7=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q7:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">true</Value></Property><Property><Name>IsKeyword</Name><Value xmlns:q8=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q8:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>TargetTemplate</Name></Property><Property><Name>CreateValuesInEditForm</Name><Value xmlns:q9=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q9:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value></Property><Property><Name>FilterAssemblyStrongName</Name><Value xmlns:q10=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q10:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">Microsoft.SharePoint.Taxonomy, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Value></Property><Property><Name>FilterClassName</Name><Value xmlns:q11=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q11:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">Microsoft.SharePoint.Taxonomy.TaxonomyField</Value></Property><Property><Name>FilterMethodName</Name><Value xmlns:q12=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q12:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">GetFilteringHtml</Value></Property><Property><Name>FilterJavascriptProperty</Name><Value xmlns:q13=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q13:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">FilteringJavascript</Value></Property></ArrayOfProperty></Customization></Field>",
    "Scope": "/sites/development/Lists/Partners",
    "Sealed": false,
    "ShowInFiltersPane": 0,
    "Sortable": false,
    "SspId": "5e76d934-89d8-476d-a29f-379cd1d37584",
    "StaticName": "Sectors",
    "TargetTemplate": null,
    "TermSetId": "c6c7e0c1-3e32-4f8f-9c31-d4b6b0582a9e",
    "TextField": "46f582c6-b2a5-4035-9ae6-dff9e4ab8ee2",
    "Title": "Sectors",
    "TypeAsString": "TaxonomyFieldTypeMulti",
    "TypeDisplayName": "Managed Metadata",
    "TypeShortDescription": "Managed Metadata",
    "UnlimitedLengthInDocumentLibrary": false,
    "UserCreated": false,
    "ValidationFormula": null,
    "ValidationMessage": null
}`

Terms Structure:

3333

@michaelmaillot
Copy link
Collaborator

Ok I can repro the issue.

If I'm not mistaken, we shouldn't end up in the last else block (in the screen) as this one is reached for a new item. We should be inside the first if block that parses the Taxonomy array values. And neither you and me have a property called "results" in the defaultValue.

@IRRDC following what you've stated here, I would like to get more info regarding your use case (list / library, field properties, site context,...), if you don't mind.

I want to understand what are we missing here, even if I realized that I didn't push far enough tests when merging the PR #1718...

@IRRDC
Copy link
Contributor

IRRDC commented Jan 11, 2024

@michaelmaillot Thanks for looking into this. I had to search for a while and noticed that back in August I got my information from my web part stopping on the error in the compiled code.
Here is the screenshot from back then:
258001797-aa0fd8c4-592f-4f5d-af9e-315a4f850b8f
While I'm directly debugging in the checked out TypeScript code where the data seems not to be split into __metadata and results:
Zwischenablage01
So I guess a better check to see if item and item[field.InternalName] exist should have been enough.

@IRRDC
Copy link
Contributor

IRRDC commented Jan 11, 2024

I created a new fix (to fix the fix): #1736

@michaelmaillot michaelmaillot added status:fixed-next-drop Issue will be fixed in upcoming release. type:bug and removed Needs: Triage 🔍 labels Jan 18, 2024
@michaelmaillot
Copy link
Collaborator

Hi @IRRDC & @bva999,

A new version has been released which includes this fix.

Can you check and tell me if that's ok for you?

@IRRDC
Copy link
Contributor

IRRDC commented Jan 19, 2024

@michaelmaillot I have mixed results. In my existing web part solution I'm back to my original problem, where in the compiled code item[field.InternalName] contains a sub-property "results" which has to be iterated. My original fix worked for that in the compiled code from the npm package.
I have created a new web part and just added the dynamic form with references to the same list and in that one the returned data structure is different and as expected.
grafik
I have not been able to figure out the reason for this. Maybe doing manual calls to @pnp/sp in some parts of the code leads to the inclusion of @pnp/sp 3.22.0 in the compiled package and incompatibilities with 2.5.0 required by controls-react. I'll try to test that next. At the moment I can see both versions of @pnp/sp in separate folders of node_modules in my solution.

@michaelmaillot
Copy link
Collaborator

Thanks for this feedback. This is strange indeed and I couldn't reproduce the .results thing you're facing.

Are you suggesting that @pnp/sp 3.x returns data in a different format than 2.x version?

@IRRDC
Copy link
Contributor

IRRDC commented Jan 19, 2024

That's what I thought first but I haven't been able to reproduce the error in the newly created web part and have by now copied nearly all the code and all the settings from the one that throws the error (and produces the additional "results" property).

@bva999
Copy link
Author

bva999 commented Jan 22, 2024

Hi @IRRDC & @bva999,

A new version has been released which includes this fix.

Can you check and tell me if that's ok for you?

Hi @michaelmaillot. It's works for me.

@michaelmaillot
Copy link
Collaborator

@IRRDC did you figure out the results origin?

@IRRDC
Copy link
Contributor

IRRDC commented Jan 22, 2024

No, it's very frustrating. I've spent days on it and created new working solutions and then suddenly the dynamic form failed to load again because the data was in "results" again. I thought I had a issue free version a few hours ago but it fails when testing on a different SharePoint tenent. I will create a new solution again tomorrow and see if it fails from the start on that tenent.

@IRRDC
Copy link
Contributor

IRRDC commented Jan 23, 2024

I started again with a new solution and a HelloWorld web part with just the dynamic form and it can display list A from site X on tenant 1 and list B on site Y on tenant 1 and list C on tenant 2.
Yesterday's solutions that started the same way and got the code of our actual web parts added to them can display a sub set of those three test lists. Some can display none of the three, some can only display list A, etc. It is consistent which solution can display which list. When it doesn't work it's because "results" got added to the data.
The only explanation I can come up with is that different versions of the very long list of packages don't get resolved perfectly when the code gets comiled into a single js file. I had a similar problem about a year ago when it was very important in which order I installed the spfx-controls-react and spfx-property-controls because they used different versions of pnp/sp and even though those different versions ended up in their node_modules folders one of them used not their own version but the one from the base folder. That caused errors during compilation which where much easier to spot.
Can we add a fallback for this weird case, like:
if (item[field.internalname].hasownproperty('results')) { item[field.internalname] = item[field.internalname]['results']; }
?

IRRDC added a commit to IRRDC/sp-dev-fx-controls-react that referenced this issue Jan 24, 2024
A possible fix for pnp#1733 when the data gets returned in a non-standard way.
@IRRDC
Copy link
Contributor

IRRDC commented Jan 24, 2024

I created another fix and copied the compiled code into my solution where it is now able to load the form for all sites and lists. #1744

@IRRDC
Copy link
Contributor

IRRDC commented Jan 30, 2024

Any thoughts?

@joelfmrodrigues joelfmrodrigues added this to the 3.17.0 milestone Feb 5, 2024
@joelfmrodrigues joelfmrodrigues mentioned this issue Feb 5, 2024
@joelfmrodrigues joelfmrodrigues added status:fixed Issue fixed in current or prior release. and removed status:fixed-next-drop Issue will be fixed in upcoming release. labels Feb 6, 2024
@IRRDC
Copy link
Contributor

IRRDC commented Feb 7, 2024

@joelfmrodrigues Why did you close the bug without comment when there is an open pull request to fix existing issues?

@joelfmrodrigues
Copy link
Collaborator

@IRRDC thanks for the heads up, I may have mistaken this with another issue from a different PR from @michaelmaillot
Please give us a moment to check and I will reopen it if required.

@IRRDC
Copy link
Contributor

IRRDC commented Feb 7, 2024

During a quick test this morning I couldn't reproduce the issue with the new version but I could not perform all test scenarios due to this new issue in the dynamic form #1758

@michaelmaillot
Copy link
Collaborator

@joelfmrodrigues Why did you close the bug without comment when there is an open pull request to fix existing issues?

Hi @IRRDC this issue has been closed because its original PR (which was a rollback from has been released in 3.16.1) has been merged and closed, then released in minor version.

Your PR is linked to a global behavior for which we didn't figure out the root cause, thus not linked to this issue in particular.

Before addressing this one, we need to understand what causes this results sub-array to appear unconsistently, not only providing a solution that can handle both scenarios. We'll keep your PR open meanwhile of course.

I'll open a new issue.

@michaelmaillot
Copy link
Collaborator

Done #1759

IRRDC added a commit to IRRDC/sp-dev-fx-controls-react that referenced this issue Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed Issue fixed in current or prior release. type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants