Hi all, I have a checklist where by default very firt is assigned and next one is assigned when the cirrent is marked as completedâŚI am getting the next checklistitem name correctly but the issue is not getting the correct date for example for âweek 1â I want to add 7 days and when the existing one is marked as completed then âweek 1â should be assigned with 7 days added i.e. if previous marked on 31 then adding 7 days to 31 should give the next monthâs 7âŚ
below is the script Iâm struggling for getting correctDate. @Jason if you could help?
// Complete checklist with intervals between sequential steps
let nextChkLstItem = ââ;
let nextchecklistItmDate = null;
if (var_checklist == âCongratulate the new Recruitâ) {
nextChkLstItem = âWeek 1 Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when this step is completed)
nextDate.setDate(nextDate.getDate() + 7); // Week 1 in 7 days
nextchecklistItmDate = nextDate;
}
else if (var_checklist == âWeek 1 Check-in - Phone Callâ) {
nextChkLstItem = âWeek 2 Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when Week 1 is completed)
nextDate.setDate(nextDate.getDate() + 7); // Week 2 in 7 days from Week 1
nextchecklistItmDate = nextDate;
}
else if (var_checklist == âWeek 2 Check-in - Phone Callâ) {
nextChkLstItem = âWeek 3 Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when Week 2 is completed)
nextDate.setDate(nextDate.getDate() + 7); // Week 3 in 7 days from Week 2
nextchecklistItmDate = nextDate;
}
else if (var_checklist == âWeek 3 Check-in - Phone Callâ) {
nextChkLstItem = â1 Month Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when Week 3 is completed)
nextDate.setDate(nextDate.getDate() + 7); // 1 month check in 7 days from Week 3 (total ~30 days from start)
nextchecklistItmDate = nextDate;
}
else if (var_checklist == â1 Month Check-in - Phone Callâ) {
nextChkLstItem = âMonth 2 Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when 1 month is completed)
nextDate.setDate(nextDate.getDate() + 30); // Month 2 in 30 days from Month 1
nextchecklistItmDate = nextDate;
}
else if (var_checklist == âMonth 2 Check-in - Phone Callâ) {
nextChkLstItem = â1st Qtr Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when Month 2 is completed)
nextDate.setDate(nextDate.getDate() + 30); // 1st Quarter in 30 days from Month 2 (total ~90 days)
nextchecklistItmDate = nextDate;
}
else if (var_checklist == â1st Qtr Check-in - Phone Callâ) {
nextChkLstItem = â2nd Qtr Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when 1st Quarter is completed)
nextDate.setDate(nextDate.getDate() + 90); // 2nd Quarter in 90 days from 1st Quarter (total ~180 days)
nextchecklistItmDate = nextDate;
}
else if (var_checklist == â2nd Qtr Check-in - Phone Callâ) {
nextChkLstItem = â3rd Qtr Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when 2nd Quarter is completed)
nextDate.setDate(nextDate.getDate() + 90); // 3rd Quarter in 90 days from 2nd Quarter (total ~270 days)
nextchecklistItmDate = nextDate;
}
else if (var_checklist == â3rd Qtr Check-in - Phone Callâ) {
nextChkLstItem = â1 Year Anniversary Check-in - Phone Callâ;
let nextDate = new Date(); // Today (when 3rd Quarter is completed)
nextDate.setDate(nextDate.getDate() + 90); // 1 Year Anniversary in 90 days from 3rd Quarter (total ~365 days)
nextchecklistItmDate = nextDate;
}
else if (var_checklist == â1 Year Anniversary Check-in - Phone Callâ) {
nextChkLstItem = âCompleted - No more stepsâ;
nextchecklistItmDate = null; // No more future dates needed
}
else {
nextChkLstItem = âUnknownâ;
nextchecklistItmDate = new Date();
}
// Return the result
var_nextchecklistitemdate = nextchecklistItmDate ? nextchecklistItmDate.toISOString().split(âTâ)[0] : null