Note: Holidays are implemented as custom record
function setTaskDateCreation(){
var daysToAdd=5; //number of days based on use case
//var dateCreated=nlapiDateToString(new Date());
var dateCreated=nlapiGetFieldValue('trandate');
var dateOfTask;
for(var i=1; i<=daysToAdd; i++){
dateOfTask=nlapiAddDays(nlapiStringToDate(dateCreated), i);
var holiday;
holiday= isHoliday(dateOfTask);
if(holiday==true)
daysToAdd = daysToAdd + 1;
}
return dateOfTask;
}
function isHoliday(dateToCheck){
var filters= new Array();
filters[0]= new nlobjSearchFilter('custrecord_date', null, 'on', nlapiDateToString(dateToCheck));
var results=nlapiSearchRecord('customrecord_holidays', null, filters,null);
if(results!=null){
return true;
}
return false;
}
No comments:
Post a Comment