How to change daysUntil date formatting dynamically

Hey Everyone,

Is it possible to change the daysUntil date formatting dynamically to weeksUntil, or monthsUntil ?

For example, I have the following scenario:
I have a select input with 3 options: Daily, Weekly, Monthly called repeatFrequency
I have a datetime variable displaying the current datetime called varTimeNow
I have a datepicker input called endDate
And I have an input called recurranceFrequency that calculates the number of times a certain action should run based on the inputs above.

I would like to have the recurranceFrequency input to be calculated automatically when the endDate field value is updated. This would be easy to do if I needed to calculate only for daily frequency, as I could have used

dmx-bind:value="varTimeNow.datetime.daysUntil(endDate.value)">

However I need to know if I can change the daysUntil part of the expression dynamically based on the repeat frequency selection. Is this possible?

If not the only alternative I can think of is to create 3 inputs for recurranceFrequency and show only one of them based on the repeatFrequency selection

Based on the frequency selected in the select dropdown, you’ll have to setup the ‘daysUntil’, ‘weeksUntil’ using ternary operators or if flow is available in your event, then you can add conditions in the flow to setup the 3 function separately.
A function cannot be setup dynamically, yet.

Got it. I used the flow option to set it up dynamically and it worked just fine

1 Like