Hi Randy,
@RandyHayes
Yes I would like the records in the database updated using the date formula shown in previous posts.
I have worked on it a bit more and came up with this formula, which seems to work for what I need, except the only behavioral option I see is the OnSelect event in the Gallery.
Switch(ThisItem.CLSUnitFrequency.Value,
"Week",
If(DateDiff(DateValue(Text(ThisItem.CLSUnitResetDate)) ,Now()) > 7, Patch(ConsumerData,ThisItem,{CLSUnitResetDate: Now()})),
"Month",
If(DateDiff(DateValue(Text(ThisItem.CLSUnitResetDate)) ,Now()) > 30, Patch(ConsumerData,ThisItem,{CLSUnitResetDate: Now()})),
"Year",
If(DateDiff(DateValue(Text(ThisItem.CLSUnitResetDate)) ,Now()) > 365, Patch(ConsumerData,ThisItem,{CLSUnitResetDate: Now()}))
);
Switch(ThisItem.SIPUnitFrequency.Value,
"Week",
If(DateDiff(DateValue(Text(ThisItem.SIPUnitResetDate)) ,Now()) > 7, Patch(ConsumerData,ThisItem,{SIPUnitResetDate: Now()})),
"Month",
If(DateDiff(DateValue(Text(ThisItem.SIPUnitResetDate)) ,Now()) > 30, Patch(ConsumerData,ThisItem,{SIPUnitResetDate: Now()})),
"Year",
If(DateDiff(DateValue(Text(ThisItem.SIPUnitResetDate)) ,Now()) > 365, Patch(ConsumerData,ThisItem,{SIPUnitResetDate: Now()}))
)
That means the records are only updated if the user clicks on the Gallery Row. There must be another way. I have looked at using a ForAll formula which looks through the entire List and placed the following the formula in the OnVisible event of the Screen.
Something like:
ForAll(var_ConsumerDatabase,
If(CLSUnitFrequency.Value = "Week",
If(DateDiff(DateValue(Text(CLSUnitResetDate)), Now()) >= 7, Patch(ConsumerData,{CLSUnitResetDate: Now()}))));
ForAll(var_ConsumerDatabase,
If(CLSUnitFrequency.Value = "Month",
If(DateDiff(DateValue(Text(CLSUnitResetDate)), Now()) >= 30, Patch(ConsumerData,{CLSUnitResetDate: Now()}))));
ForAll(var_ConsumerDatabase,
If(CLSUnitFrequency.Value = "Year",
If(DateDiff(DateValue(Text(CLSUnitResetDate)), Now()) >= 365, Patch(ConsumerData,{CLSUnitResetDate: Now()}))));
This is giving me a runtime error at the moment.
Any other suggestions on how this can be managed?
Thanks!