Updating date fields on priority field change

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Jaydius
Posts: 43
Joined: Thu Nov 12, 2015

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.

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

13 Apr 2016

This should help you:

Code: Select all

var duedate = fd.field('Reportedon').control('getDate');
duedate.setDate(duedate.getDate() + 1); //increment days by one

Jaydius
Posts: 43
Joined: Thu Nov 12, 2015

13 Apr 2016

Perfect. Thanks for your help.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests