Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Automatically Setting the Due Date in an Invoice
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Automatically Setting the Due Date in an Invoice

 Post Reply Post Reply Page  <12
Author
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4071
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jun 2017 at 4:56pm
You only need to add the additional code for computing the due date and filling in the due date field to your function.

function date() {
     var oSysDate = new Date(); // get the systems date object;
      var oDateField = this.getField("DateField"); // get today's date field;
      if(oDateField.defaultValue == "")
      {
           oDateField.value = util.printd("dd mmmm yyyy", oSysDate); // fill with formatted date;
//           oDateField.defaultValue = oDateField.value; // set default value;
          var oDue = new Date();
          oDue.setDate(oDue.getDate() + 30);
           var oDueDate = this.getField("DueDate"); // get due date field object;
           oDueDate.value = util.printd("dd mmm yyyy", oDue); // fill in due date;
//           oDueDate.defautlValue = oDueDate.value; // set value so it does not reset;
     } // end date field not set
} // end date function;

date(); // call my function


Edited by gkaiseril - 30 Jun 2017 at 5:03pm
Back to Top
Sponsored Links


Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4071
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jun 2017 at 5:07pm
I would add the necessary code to compute the future date and set the due date field to your original function.

function date() {
     var oSysDate = new Date(); // get the systems date object;
      var oDateField = this.getField("DateField"); // get today's date field;
      if(oDateField.defaultValue == "")
      {
           oDateField.value = util.printd("dd mmmm yyyy", oSysDate); // fill with formatted date;
//           oDateField.defaultValue = oDateField.value; // set default value;
          var oDue = new Date();
          oDue.setDate(oDue.getDate() + 30);
           var oDueDate = this.getField("DueDate"); // get due date field object;
           oDueDate.value = util.printd("dd mmm yyyy", oDue); // fill in due date.
           oDueDate.defautlValue = oDueDate.value; // set value so it does not reset;
     } // end date field not set
} // end date function;

date(); // call my function;

You can also set the function to only update the date and due date if the default value of the date field is empty. This will prevent the field from being updated each time the form is entered and also stop the field from being reset if the form is reset.
Back to Top
Andy63 View Drop Down
New Member
New Member
Avatar

Joined: 27 Jun 2017
Points: 8
Post Options Post Options   Quote Andy63 Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2017 at 3:41am
Hi Everyone,

Thanks for the help, finally found a script that works:
var oDate = new Date();
console.println("DateField" + util.printd("dd/mm/yyyy", oDate));
// get the date of the month;
var nDate = oDate.getDate();
// add 30 days;
nDate += 30;
// set the date;
oDate.setDate(nDate);
console.println("DueDate" + util.printd("dd/mm/yyyy", oDate));
Back to Top
 Post Reply Post Reply Page  <12
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.018 seconds.