Skip to content

[Fix] correctly handle dates in function parameters#446

Merged
Power-Maverick merged 1 commit into
PowerPlatformToolBox:devfrom
drivardxrm:fix/handle-date-in-function-api
Mar 9, 2026
Merged

[Fix] correctly handle dates in function parameters#446
Power-Maverick merged 1 commit into
PowerPlatformToolBox:devfrom
drivardxrm:fix/handle-date-in-function-api

Conversation

@drivardxrm

Copy link
Copy Markdown
Contributor

Currently date parameters are not well resolved in function execution.

If a date parameter is sent in a function call, we receive an error like this.

Custom API 'driv_FuncApi' execution failed: Error invoking remote method 'dataverse.execute': Error: Dataverse execute failed: 0x80060888: Syntax error: character '"' is not valid at position 0 in '"2026-03-04T05:00:00.000Z"'.

This PR correctly handles date parameters by converting them appropriately

In method formatFunctionParameter of DataverseManager

// Handle dates - convert to ISO string
if (value instanceof Date) {
     return value.toISOString();
}

Copilot AI review requested due to automatic review settings March 8, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect handling of date parameters when invoking Dataverse function APIs. When a Date object is passed as a function parameter, the formatFunctionParameter method now detects it via instanceof Date and converts it to an ISO string before URL construction. Without this, the date would fall through to the generic object path and be JSON-serialized with surrounding double-quotes, which Dataverse rejects.

Changes:

  • Adds an instanceof Date branch in formatFunctionParameter (in DataverseManager) that converts a Date to its ISO string representation before it is embedded in the OData function URL query string.

Comment thread src/main/managers/dataverseManager.ts
@Power-Maverick Power-Maverick self-requested a review March 9, 2026 14:48
@Power-Maverick Power-Maverick merged commit d1b2150 into PowerPlatformToolBox:dev Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants