Updating date fields on priority field change
Posted: 12 Apr 2016
Im trying to adjust two date fields when a choice field is changed ('Priority'). Based on the radio button choice, the dates need to be calculated using the 'Reportedon' date/time field, then updated in their respective fields. Heres my code:
fd.field('Priority').change(function(){
var duedate = new Date();
var shedate = new Date();
var orgdate = fd.field('Reportedon').value();
if (fd.field('Priority').value() == '0') {
duedate.setDate(orgdate + 1);
shedate.setDate(orgdate + 1);
} else if (fd.field('Priority').value() == '1') {
duedate.setDate(orgdate + 7);
shedate.setDate(orgdate + 7);
} else if (fd.field('Priority').value() == '2') {
duedate.setDate(orgdate + 14);
shedate.setDate(orgdate + 7);
} else if (fd.field('Priority').value() == '3') {
duedate.setDate(orgdate + 30);
shedate.setDate(orgdate + 14);
} else if (fd.field('Priority').value() == '4') {
duedate.setDate(orgdate + 182);
shedate.setDate(orgdate + 152);
} else if (fd.field('Priority').value() == '5') {
duedate.setDate(orgdate + 365);
shedate.setDate(orgdate + 305);
} else {
}
fd.field('NextDue').value(duedate);
fd.field('NextScheduled').value(shedate);
});
Appreciate any help.
fd.field('Priority').change(function(){
var duedate = new Date();
var shedate = new Date();
var orgdate = fd.field('Reportedon').value();
if (fd.field('Priority').value() == '0') {
duedate.setDate(orgdate + 1);
shedate.setDate(orgdate + 1);
} else if (fd.field('Priority').value() == '1') {
duedate.setDate(orgdate + 7);
shedate.setDate(orgdate + 7);
} else if (fd.field('Priority').value() == '2') {
duedate.setDate(orgdate + 14);
shedate.setDate(orgdate + 7);
} else if (fd.field('Priority').value() == '3') {
duedate.setDate(orgdate + 30);
shedate.setDate(orgdate + 14);
} else if (fd.field('Priority').value() == '4') {
duedate.setDate(orgdate + 182);
shedate.setDate(orgdate + 152);
} else if (fd.field('Priority').value() == '5') {
duedate.setDate(orgdate + 365);
shedate.setDate(orgdate + 305);
} else {
}
fd.field('NextDue').value(duedate);
fd.field('NextScheduled').value(shedate);
});
Appreciate any help.