This solution is applicable for all record types on which there is a field type of date and its default value is current date. However if current date isn't our required day of week, using SuiteScript it will be recalculated and retrieved the date of the following required day of week upon saving of the record.
The script sample below is considering that required day of week is Friday.In order to achieve the date recalculation for other values of required day of week (e.g.: Mon, Tue, etc.), it is necessary to edit the definition of the variable named as "difference" accordingly.Afterwards deploy the script as server-side script on AfterRecordSubmit trigger type in order to perform date recalculation on saving of the record.
Sample:
var weekDayDate = new Date();
var dayofWeek = weekDayDate.getDay();
var difference = 5 - dayofWeek;
if (difference > 0)
weekDayDate.setDate(weekDayDate.getDay() + difference);
else
weekDayDate.setDate(today.getDay() + 7);
nlapiLogExecution('DEBUG', weekDayDate);
}
No comments:
Post a Comment