Expand my Community achievements bar.

Join expert-led, customer-led sessions on Adobe Experience Manager Assets on August 20th at our Skill Exchange.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

Livecycle ES4 Javascript Assistance (Expiration Date based on 2 Criteria)

Avatar

Level 1

Good afternoon. I'm a contractor for Air Force Training and we still have Livecycle for training form development.

I'm modifying an Air Force Evaluation Form to automatically calculate an expiration date based on date of initial evaluation and status (Active Duty, Guard, Reserve).

If the member is Active Duty, the expiration date would be 18 months, but on the 1st of the 18th month.

If the member is Guard or Reserve, the expiration date would be 36 months, but on the 1st of the 36th month.  Below is the script I wrote (bound to Expiration Date):

var status = this.getField("STATUS").value;

var evalD = util.scand("yyyy-mm-dd", this.getField("DATEOFEVALUATION").value);

var expD = new Date();

if( status == "Active Duty") {

    expD.setFullYear(evalD.getFullYear(), evalD.getMonth()+18, evalD.getDate());

}

else {

    expD.setFullYear(evalD.getFullYear(), evalD.getMonth()+36, evalD.getDate());

}

if( expD.getMonth() == 1) {

    expD.setDate(28);

}

if( expD.getMonth == 3 || expD.getMonth == 5 || expD.getMonth == 8 || expD.getMonth == 10) {

    expD.setDate(30);

}

var status = this.getField("STATUS").value;

var evalD = util.scand("yyyy/mm/dd", this.getField("DATEOFEVALUATION").value);

var expD = new Date();

if( status == "Active Duty") {

    expD.setFullYear(evalD.getFullYear(), evalD.getMonth()+18, evalD.getDate());

}

else {

    expD.setFullYear(evalD.getFullYear(), evalD.getMonth()+36, evalD.getDate());

}

if( expD.getMonth() == 1) {

    expD.setDate(28);

} else if( expD.getMonth() == 3 || expD.getMonth() == 5 || expD.getMonth() == 8 || expD.getMonth() == 10) {

    expD.setDate(30);

} else {

    expD.setDate(31);

}

  1. event.value = util.printd("yyyymmdd",expD);

if( expD.getMonth == 0 || expD.getMonth == 2 || expD.getMonth == 4 || expD.getMonth == 6 || expD.getMonth == 7 || expD.getMonth == 9 || expD.getMonth == 11)  {

    expD.setDate(31);

}

  event.value = util.printd("yyyymmdd",expD);

I haven't had luck for the calculation to work after entering the Evaluation Date and the Military status.  Any help is greatly appreciated.  Thanks, Mike

0 Replies