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

Workflow - Some Date calculations fail with certain formats #9902

Closed
SinergiaCRM opened this issue Jan 18, 2023 · 0 comments · Fixed by #9903
Closed

Workflow - Some Date calculations fail with certain formats #9902

SinergiaCRM opened this issue Jan 18, 2023 · 0 comments · Fixed by #9903
Labels
Area: Workflow Issues & PRs related to all things regarding workflow Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase

Comments

@SinergiaCRM
Copy link
Contributor

SinergiaCRM commented Jan 18, 2023

When having a workflow action that runs on schedulers and calculates a date field using the date formulas provided https://docs.suitecrm.com/user/advanced-modules/workflow-calculated-fields/ , the results are wrong with certain combination of user date formats and values.

WFdateField

This can be reproduced if the user has the date format dd/mm/YYYY, and the day value is higher than 12, for example 15/12/2022. In this case, when applying the function {datediff({P0}; {now(Y-m-d)} ; months )} the DateTime function can't convert properly the "15/12/2022" date and it returns error.

The issue is also replicable in "On save" Workflows if the date is hard-coded in the formula.

Issue

Date field calculation gives error with certain formats and values

Expected Behavior

It should work with any format and values.

Actual Behavior

The workflow fails and the date isn't calculated.

Possible Fix

Detect user format and convert to DB/UTC format in those cases that are needed.

Steps to Reproduce

  1. Set the User date format in Profile Advance option to "23/12/2010"
  2. Create a workflow with a Calculate field action (Contacts based)
  3. Add a date field parameter as parameter (birthdate)
  4. Add a formula to a text field. (Formula: {datediff({P0}; {now(Y-m-d)} ; months )} to description field)
  5. Create a contact with 14/12/2020 in birthdate
  6. Run the workflow on Scheduler and check that it failed calculating the date

Context

This should work as expected

Your Environment

  • SuiteCRM Version used: 7.12.8
  • Browser name and version: Versión 107.0.5304.121 (Build oficial) (64 bits)
  • Environment name and version: MariaDB 10.6.5, PHP 7.4
  • Operating System and version : KDE Neon 5.26
@SinergiaCRM SinergiaCRM changed the title Workflow - Some Date calculation give wrong results running on Scheduler Workflow - Some Date calculation give wrong results Jan 18, 2023
@SinergiaCRM SinergiaCRM changed the title Workflow - Some Date calculation give wrong results Workflow - Some Date calculations fail with certain formats Jan 18, 2023
AlbertoSTIC pushed a commit to SinergiaTIC/SuiteCRM that referenced this issue Jan 18, 2023
@gemartin21 gemartin21 added Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Area: Workflow Issues & PRs related to all things regarding workflow labels Jan 24, 2023
@johnM2401 johnM2401 added Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Type: Bug Bugs within the core SuiteCRM codebase labels Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Workflow Issues & PRs related to all things regarding workflow Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants