Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to set a date range to be current month to 12 months back, which works correctly in my trigger with the following expression
='>=' & AddMonths(max(OrderDateMMDDYYYY), -12 , 0 ) & '<=' & Date(max(OrderDateMMDDYYYY))
I only want to set that if there is not a selection already made on that field - I tried using
=IF (GetSelectedCount(OrderDateMMDDYYYY) = 0,'>=' & AddMonths(max(OrderDateMMDDYYYY), -12 , 0 ) & '<=' & Date(max(OrderDateMMDDYYYY))) - this would select the date range only if there was not a value previously selected for that field - this problem being encountered with the statement above is if there is a selection within the field from another tab, when I go to the tab, there are no items selected -
If the OrderDateMMDDYYYY has a selected value, then leave as is, if it does not, set it to current month through 12 months back - this is being done via a trigger on select in field OnActivate sheet - It only seems to work when there is nothing selected
You could use an appropriate expression for the ELSE branch of your if() statement to keep your selection, but I think there is an easier solution:
As search string, leave your original expression unchanged:
='>=' & AddMonths(max(OrderDateMMDDYYYY), -12 , 0 ) & '<=' & Date(max(OrderDateMMDDYYYY))
Now, for the field,where you previously used
OrderDateMMDDYYYY
(as far as I've understood), use your condition:
=if( GetSelectedCount(OrderDateMMDDYYYY) = 0, 'OrderDateMMDDYYYY',NULL())
it looks like the following performs as I needed - if the are selections made, keep date selected, but if there are not any selects, set the date field to be current plus 12 months back
=IF (count(GetCurrentSelections() > 0),GetFieldSelections(OrderDateMMDDYYYY),('>=' & AddMonths(max(OrderDateMMDDYYYY), -12 , 0 ) & '<=' & Date(max(OrderDateMMDDYYYY))))