Updating date fields on priority field change

rss

Posted by Jaydius - Apr 12 ’16 at 07:11

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.

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 7 months 4 days
    #1 by rostislav Apr 13 ’16 at 04:59

    This should help you:

    var duedate = fd.field('Reportedon').control('getDate');
    duedate.setDate(duedate.getDate() + 1); //increment days by one 
  • Jaydius
    Member
    Member for: 6 years 26 days
    #2 by Jaydius Apr 13 ’16 at 03:31

    [#1]: Perfect.  Thanks for your help.

Displaying 1 to 2 of 2 messages