alexed1 / LightningFlowComponents

A collection of unofficial Flow extensions that can be used to enhance Salesforce Flow and Orchestrator.
http://unofficialsf.com
Other
590 stars 579 forks source link

*Datatable* - Date fields do not take into account Locale Settings #847

Open florebloes opened 3 years ago

florebloes commented 3 years ago

Steps to reproduce

Steps to reproduce the behavior:

  1. Screen Flow - add datatable component, display in table a date field (installed version: 3.3)
  2. When in a record, type in date column for a line a date eg. 16th october
  3. Save
  4. You will see that the date being displayed in the datatable is the 15th of October, however, when you navigate to the actual record, it's save as the 16th of October

note - I am not using any special attributes in the datatable

Expected behaviour

Datatable component should take into account locale settings for date & time. (checked the V2 code, here I saw you do use type "date locale", however, not sure if you are using this in the newest release as well ? )

Actual behaviour

Displays date - 1 day in the component, while it is being saved in the background as the actual entered date when you navigate into the actual record .

Screenshots

Datatable view before save: image

Datatable view after save: image

Record field in the record: image

ericrsmith35 commented 3 years ago

The component uses a time-zone offset value for the running user to display dates correctly when the records are first read into the component. Any field edits will show as the internal system values until the records are read back into a new datatable.

florebloes commented 3 years ago

@ericrsmith35 not clear to me. It's a screen flow I embedded on the record page. So when navigating back and forth to the record, the flow constantly gets triggered and each time gets the quote line items. So the edits are each time read back into the datatable as the flow gets 'loaded' again.

Here is overview of entire flow : image

florebloes commented 3 years ago

Hi @ericrsmith35 could you please review my question again! Thanks in advance!

ericrsmith35 commented 3 years ago

It looks like the correct date is being saved in the record. Are you seeing the wrong date the next time the records are loaded and displayed in the datatable?

florebloes commented 3 years ago

@ericrsmith35 yes. The flow is just a component on my lightning record page. So each time I navigate back to the record, the flow is displayed, meaning each time the data is loaded back into the datable

florebloes commented 3 years ago

@ericrsmith35 Any feedback Yet?

Dietermartens commented 3 years ago

@ericrsmith35 I'm having the same issue here... our dates are correct on the record, but in the datatable they are displayed minus one day (it looks like it's converted to datetime and then displayed in UTC).

ericrsmith35 commented 3 years ago

Can you share some screenshots of this happening and what timezone you are in and what time of day this is happening?

On Mon, Aug 23, 2021 at 11:45 AM Dietermartens @.***> wrote:

@ericrsmith35 https://github.com/ericrsmith35 I'm having the same issue here... our dates are correct on the record, but in the datatable they are displayed minus one day (it looks like it's converted to datetime and then displayed in UTC).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alexed1/LightningFlowComponents/issues/847#issuecomment-903891462, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4UHX3U5IM53D34EGTGF3TT6JUKPANCNFSM5BZUV4XA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

Dietermartens commented 3 years ago

Hi Eric,

We are base GMT+2 but it should not matter because it's a DATE field and not a DATATIME. It's actually as @florebloes described and showed, on the record, the date is saved and displayed correctly and in the datatable it is always -1 day. Our Salesforce is on userlevel and system eleven configured to use GMT+2.

As far as I can see it's always happening

florebloes commented 3 years ago

@ericrsmith35 any further feedback on this?

florebloes commented 3 years ago

Hi @ericrsmith35 , here is the solution to the problem. Works now after this adjustment in the code

WHAT? Datatable for planning is showing wrong date (minus 1) A screen flow using datatable was created, however in the javascript of this component there needs some code adjustment because else the date is shown minus -1 day in the datatable itself.

lwc component : database

file : database.js => comment/remove the part that is commented in the snippet below. This date conversion happening here is not necessary anymore. (was a bug in the standard sf datatable component)

// Adjust date with offset based on User's timezone
        dateFields.forEach(date => {
            if (record[date]) {
               let dt = Date.parse(record[date]);
                let d = new Date();
                record[date] = new Date(d.setTime(Number(dt) - Number(this.timezoneOffset)));
            }
        }); 
ericrsmith35 commented 3 years ago

I see the opposite issue in v3.2.2. The table shows the correct date and the record stores the correct date. If I comment out that section, the record still stores the correct date, but the table displays one day earlier.

On Thu, Sep 2, 2021 at 1:56 AM Flore Bloes @.***> wrote:

Hi Erik, here is the solution to the problem. Works now after this adjustment in the code

WHAT? Datatable for planning is showing wrong date (minus 1) A screen flow using datatable was created, however in the javascript of this component there needs some code adjustment because else the date is shown minus -1 day in the datatable itself.

lwc component : database

file : database.js => comment/remove the part that is commented in the snippet below. This date conversion happening here is not necessary anymore. (was a bug in the standard sf datatable component)

// Adjust date with offset based on User's timezone dateFields.forEach(date => { if (record[date]) { let dt = Date.parse(record[date]); let d = new Date(); record[date] = new Date(d.setTime(Number(dt) - Number(this.timezoneOffset))); } });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alexed1/LightningFlowComponents/issues/847#issuecomment-911226421, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4UHXYQE2QI42BX3RAS5NDT74GYXANCNFSM5BZUV4XA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ericrsmith35 commented 2 years ago

@florebloes @Dietermartens I have implemented a bug fix for the Datatable component where dates could sometimes be off by 1 day. This would typically happen when the date being displayed, and the current date had a mismatch with one of them being in Daylight Savings time and the other one was not.

Before publicly publishing this fix, I would like to get feedback from users that had experienced the issue. Please install the current versions of the UnofficialSF Base Packs (https://unofficialsf.com/flow-action-and-screen-component-basepacks/) then install Version 4.0.4 of the Datatable component.

Sandbox (https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000003rUxRQAU) Production or Dev (https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000003rUxRQAU)

Please let me know if this fixes your issue or if you are still having a problem with dates being off by one day.

Thanks, Eric Smith

frank-vdp commented 2 years ago

Hi Eric,

Your fix has rectified my problem...Due Date before update: [image: image.png]

...Due Date after update: [image: image.png]

Thanks for this Datatable component - I use it everywhere!

Cheers, Frank

On Mon, 16 May 2022 at 04:06, Eric Smith @.***> wrote:

@florebloes https://github.com/florebloes @Dietermartens https://github.com/Dietermartens I have implemented a bug fix for the Datatable component where dates could sometimes be off by 1 day. This would typically happen when the date being displayed, and the current date had a mismatch with one of them being in Daylight Savings time and the other one was not.

Before publicly publishing this fix, I would like to get feedback from users that had experienced the issue. Please install the current versions of the UnofficialSF Base Packs ( https://unofficialsf.com/flow-action-and-screen-component-basepacks/) then install Version 4.0.4 of the Datatable component.

Sandbox ( https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000003rUxRQAU ) Production or Dev ( https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000003rUxRQAU )

Please let me know if this fixes your issue or if you are still having a problem with dates being off by one day.

Thanks, Eric Smith

— Reply to this email directly, view it on GitHub https://github.com/alexed1/LightningFlowComponents/issues/847#issuecomment-1126988575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKPYLFMUEC4YWYQES5JYSODVKE4JRANCNFSM5BZUV4XA . You are receiving this because you are subscribed to this thread.Message ID: @.***>