In some circumstances you might want to split your Decision Tree into different paths based on the day of the week.

So for example Monday through Friday when you are available. While also at weekends when you are not available.

  1. create an answer text custom field called ‘weekday’.

2. Add this script to any node ( to fire on enter )

<script>
  
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var n = weekday[d.getDay()];

console.log(n);
DT.setField('weekday',n);
  
</script>

3. Now you can use the {weekday} custom field to print the current day of the week. Or use in a decision node as you like.

Demo here: https://test2.leadshook.io/survey/VD2glpEVQvtX0og37RVObukRrcP6UXRqqjvTEFRO

Leave a Reply

Your email address will not be published.