Skip to content

SPServices.ts - Function getLookupValues parses no Date values as Date #2091

@quasiFreitag

Description

@quasiFreitag

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

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

Expected / Desired Behavior / Question

I am creating a sp list form customizer with the control "dynamic form" on a list (List A) with a lookup field to List B. The lookup field targets the title field of list B as display value.

Expected behavior: The lookup value should render as the value of the title field of the linked item in List B.

Observed Behavior

The value of the title of the linked item from list B does render as a Date inside the lookup control.
When the Title of the linked item has no number at the end of the value the title renders correctly.

Examples:
Value "Lisa Gr. One" renders as "Lisa Gr. One"
Value "1 Lisa Gr." renders as "1 Lisa Gr."
Value "Lisa Gr. 1 One" renders as "Lisa Gr. 1 One"
Value "Lisa Gr. 1" renders as "01/01/2001"
Value "Lisa Gr. 123" renders as "01/01/0123"

I dont think this works as intended.

Steps to Reproduce

The behaviour should also be reproducable with the "ListItemPicker" control. The Dynamic Form / Dynamic Field is using it internally.

I tracked the issue down to the function "getLookupValues" inside the SPService.ts file.
In line 587 to 590 (and line 598 to 601) the display value is parsed as a date with Date.parse(value) and checked if it worked with Number.isNaN(dateVal).
Unfortunatelly that works with values that has a number at the end.

Sadly I do not have a quick solution for that...
Maybe the service should check if the target field is a DateTime field. But how should it do that exactly and at which point...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions