When you bind the javascript on field change event check the context from UI and define the javascript function name like this:
var year;
var weekNumber;
var selectedRow = null;
var attributeColl = null;
function dateChange(eContext) {
debugger;
var nameAttr = eContext.getEventSource();
var attrParent = nameAttr.getParent();
var startDateField = attrParent.attributes.get("new_startdate");
var date = startDateField.getValue();
//Get week number
var currentWeekNumber = parseFloat(date.getWeek());
//Get full year
const dt = new Date(date);
var currentyear = parseFloat(dt.getFullYear());
//set week value
var new_weeknumbercstField = attrParent.attributes.get("new_weeknumbercst");
new_weeknumbercstField.setValue(currentWeekNumber);
// Set year value
var new_yearcstField = attrParent.attributes.get("new_yearcst");
new_yearcstField.setValue(currentyear);
}
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(), 0, 1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}
Comments
Post a Comment