2

We have an app that is deployed onto users smartphone devices. This app is designed to capture the users "availability" for the month. The app gives them a month view of every day within a month, with a toggle switch next to each day. The user then toggles the days they can work on and hits save. The save button then uses a ForAll + Patch function to check each record. If the record exists, it updates any changes and if the record doesn't exist, it's created.

Issue

A sub set of users (under 2-5%) are experiencing an issue where the 1st day of the month sometimes doesn't show correctly (it usually defaults to false) and then when the user saves the record, it updates it to "false" for the 1st of the month. This causes the record to change to a false and then the user is confused as to why this has changed from true as they didn't change it. In just one user, we've seen an issue where the first 3 days of the month didn't display correctly and they then saved over it. This hasn't occurred for them since, so it's possible that this was an anomaly or user error and not part of this issue.

Potential Cause

The collection is built on date joins and looking up information from different tables. The dates are dynamic so have DateAdd operations on them. The app and date is stored in the UK and users are UK based. On one user who had an issue, we noticed that their time was shown on their phone in the 12 hour format and not 24 hour format (like most UK devices). So we added an offset piece of code for the TimeZone and since going into the app, it appears this has fixed it for this user. This variable replaces the below code:

Old Code:

Today()

New Code:

Set(_todayOffset, DateValue(Text(DateAdd(Now(), TimeZoneOffset(), Minutes), "[$-en-GB]dd/mm/yyyy")));

Potential Solutions

It seems unlikely that a subset of users don't have their devices set to their locale. So my question is, is there something else that could be causing this? Is there a default way of dealing with device locales and dates? Is there a way of forcing the dates to display in a certain TimeZone or locale, overriding device settings to really eliminate this potential issue? For completeness, I've added the code used to generate and save the data below:

Caching the Displayed Data (Gallery.Items bound to 'aAvail')

Set(userID, Office365Users.MyProfile().UserPrincipalName);
Set(empID, LookUp(PF_Workers, UPN = userID, 'Employee ID'));

Set(_todayOffset, DateValue(Text(DateAdd(Now(), TimeZoneOffset(), Minutes), "[$-en-GB]dd/mm/yyyy")));
Set(_firstDayOfMonth, DateAdd(Date(Year(_todayOffset), Month(_todayOffset), 0), 1, Days));
Set(_firstDayOfNextMonth, DateAdd(_firstDayOfMonth, 1, Months));
Set(_fdom_6monthBefore, DateAdd(_firstDayOfMonth, -6, Months));
Set(_fdom_6monthAhead, DateAdd(_firstDayOfMonth, 6, Months));

ClearCollect(
    aDates,
    Filter(
        PF_Dates,
        Month >= _fdom_6monthBefore,
        Month < _fdom_6monthAhead
    )
);
ClearCollect(
    aComb1,
    AddColumns(
        aDates,
        "Records",
        LookUp(
            PF_Availabilty,
            And(
                Date = aDates[@Date],
                'Employee ID' = empID
            ),
            'Record ID'
        )
    )
);
ClearCollect(
    aAvail,
    AddColumns(
        aComb1,
        "Work",
        LookUp(
            PF_Availabilty,
            'Record ID' = aComb1[@Records],
            Work
        )
    )
);

Saving the data

// Set save variable
Set(_savingData, true);

// Cache and check data in database, and then perform Patch
ClearCollect(
    avGalleryData,
    AddColumns(
        galDatePicker.AllItems,
        "AvailableToggle",
        tglAvailability.Value
    )
);
ForAll(
    avGalleryData,
    If(
        IsBlankOrError(avGalleryData[@Records]),
        Patch(
            PF_Availabilty,
            Defaults(PF_Availabilty),
            {
                'Employee ID': empID,
                Date: DateValue(Text(DateAdd(Date, TimeZoneOffset(), Minutes), "[$-en-GB]dd/mm/yyyy")),
                Month: DateValue(Text(DateAdd(Month, TimeZoneOffset(), Minutes), "[$-en-GB]dd/mm/yyyy")),
                Work: 
                If(
                    AvailableToggle = true,
                    'Work (PF_Availabilty)'.'true',
                    'Work (PF_Availabilty)'.'false'
                )
            }
        ),
        Patch(
            PF_Availabilty,
            LookUp(
                PF_Availabilty,
                'Record ID' = avGalleryData[@Records]
            ),
            {
                Work: 
                If(
                    AvailableToggle = true,
                    'Work (PF_Availabilty)'.'true',
                    'Work (PF_Availabilty)'.'false'
                )
            }
        )
    )
);

// Reloading cached data
ClearCollect(
    aComb1,
    AddColumns(
        aDates,
        "Records",
        LookUp(
            PF_Availabilty,
            And(
                Date = aDates[@Date],
                'Employee ID' = empID
            ),
            'Record ID'
        )
    )
);
ClearCollect(
    aAvail,
    AddColumns(
        aComb1,
        "Work",
        LookUp(
            PF_Availabilty,
            'Record ID' = aComb1[@Records],
            Work
        )
    )
);

// Cleanup variables
Set(_savingData, false)

Any help greatly appreciated!

RazorKillBen
  • 561
  • 2
  • 20

0 Answers0