I have a flow that changes a certain date field in the system. It is important however that the resulting date is not a Sunday. So Iβm trying to build a secondary flow that checks for this and can update the date further if needed.
I thought I would be able to use a script filter to check something such as
var date = new Date(lead_field_date_that_next_drip_message_will_be_sent_formatted);
var isSunday = date.getDay() === 0;
and filter on that but I keep getting errors. Any tips here would be appreciated!
I will describe the date-fns way of doing this as this library is much nicer than Moment.js
we will be using the isSunday() function of date-fns:
// Note: this code will not work as it is not an expression
var date = new Date(lead_field_date_that_next_drip_message_will_be_sent_formatted);
var isSunday = date_fns.isSunday(date);
As you are inside a script filter, the code above will not work as it has to be an expression. Letβs rewrite the code to an expression that works inside the script filter: