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

DynamicForm does not load or save correctly when field name starts with special character #1077

Closed
t0mgerman opened this issue Dec 9, 2021 · 2 comments · Fixed by #1126
Closed
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Milestone

Comments

@t0mgerman
Copy link

Category

[ ] Enhancement

[*] Bug

[ ] Question

Version

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

Expected Behavior

DynamicForm should display and save all field values, regardless of internal field name in SharePoint

Observed Behavior

When a field is created in SharePoint with a special character at the start of the field name, SharePoint replaces this character with a unicode representation like \_x####\_ - where #### is the unicode character reference. For example: if you name a field "% Complete" - SharePoint will call this field "_x0025_Complete" internally. To complicate matters further, the property returned from the API will be named "OData__x0025_Complete". At present, because of this difference, fields named in this way will not work in DynamicForm.

This does not affect fields where a special character is used in the middle or at the end of the field name. Only those used at the beginning.

Steps to Reproduce

  1. Add a SharePoint field to a list, beginning with a special character such as %
  2. Create or edit a list item to ensure that this field has a value
  3. Amend ControlsTest.tsx#L886 to uncomment and display the DynamicForm control, point this control at the list and list item, then view the test in Workbench
  4. Observe that the list item value does not load correctly, and values cannot be saved back to the list

Proposed Solution

The necessary data to fix this issue is already being retrieved. Instead of using field.InternalName, use field.EntityPropertyName. In most cases this matches field.InternalName - but it also matches the field property name as the SharePoint API expects it.

So on DynamicForm.tsx#L326 use:

defaultValue = item[field.EntityPropertyName];

and on DynamicForm.tsx#L458 use:

columnInternalName: field.EntityPropertyName,
@ghost
Copy link

ghost commented Dec 9, 2021

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

@ghost ghost added the Needs: Triage 🔍 label Dec 9, 2021
t0mgerman pushed a commit to t0mgerman/sp-dev-fx-controls-react that referenced this issue Dec 9, 2021
AJIXuMuK added a commit that referenced this issue Dec 21, 2021
Amend DynamicForm.tsx to use EntityPropertyName rather than InternalName - Fix for #1077
@AJIXuMuK AJIXuMuK added status:fixed-next-drop Issue will be fixed in upcoming release. and removed Needs: Triage 🔍 labels Dec 21, 2021
@AJIXuMuK AJIXuMuK added this to the 3.6.0 milestone Dec 21, 2021
@AJIXuMuK AJIXuMuK mentioned this issue Feb 12, 2022
@murtuzamj
Copy link

Any idea why the "Person Group" type fields on the list, renders an arbitrary (user) value when left blank?

Any workaround to mitigate the behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants