Calculated date offset no showing in alternate field
I am using the following code to determine if the field "WeekEndingDat" is blank, to automatically set it to the upcoming Sunday.
//declare variables; get the date string from date field object
var f = this.getField("WeekEndingDate").value;
var d = util.scand("mm/dd/yyyy", f);
var t = new Date();
var x = t.getDay();
//check if WeekEndingDate field is blank
if (f=="") {
//if blank, set date value to next Sunday
t.setDate(t.getDate()+(7-x));
//display the output of the new date in the desired date format
event.value = util.printd("mm/dd/yyyy", t);
}
else {
event.value=util.printd("mm/dd/yyyy", d);
}
This works fine for the field with the calculation when I either manually add a date or delete the data and the new upcoming Sunday date is automatically populated in this field.
I have an alternate field which is to also use the same date from the calculated field. Whenever I manually enter a date, the alternate field works properly. However, when I delete the data from the initial field, the alternate field automatically populates with the current date (not upcoming Sunday). The code for the alternate field is
// Get the date string from the date field object
var f = this.getField("WeekEndingDate").value;
var d = util.scand("mm/dd/yyyy", f);
// Display the new date in the desired format
event.value = util.printd("mm/dd/yyyy", d);
Any help is appreciated.
