Hi Alexander,
I am using the JS below to set a date field. The code is working as expected if I leave the date field as Editable in Rules, but if I set it as Read-Only with a rule when the form is initiated the code isn’t updating the field.
I am triggering the doCalculateDates function when the ‘Advance 1 Date’ field is changed.
I was using a DFFS version from a month or two ago, but just updated to the most recent version as of today (v4.4.5.26 – May 27, 2021|CSS version: 4.51 / |spjs-utility version: 1.351).
function dateOffsetDays(date, days){
var d = new Date(date.valueOf());
var nDate = d.setDate(d.getDate()+days);
return new Date(nDate);
}
function doCalculateDates(){
var advanceDate = spjs.utility.getDateFieldAsDateObject("Advance1Date");
console.log(advanceDate);
var bterm = parseFloat(jQuery("input[title='Base Term']").val().replace(/,/g, '')) || 0;
console.log(bterm);
var maturedays = bterm * 365;
console.log(maturedays);
var plusDays = dateOffsetDays(advanceDate, maturedays);
console.log(plusDays);
spjs.utility.setDateFieldFromDateObject("MaturityDate", plusDays);
}