Skip to main content
Known Participant
March 17, 2019
Answered

Have two print date boxes that needs to function on their own

  • March 17, 2019
  • 1 reply
  • 808 views

Good morning,

I posted a question in Oct 2018 about two text boxes which I wanted different print dates in them.  So far, the two text boxes are in the will print and did print functions and I managed to lock down one box from updating every time I print.  But my problem is that because the two boxes are in the print functions, a date appears in both boxes when I  click print the very first time.  I do not want that to occur.  I would like the current date to appear ONLY in the first box the first time I hit print and then any other time I hit print, I want the date to appear in the second block.   The date can change in the second block each time the form is printed after that.   Is there a way I can accomplish this? 

This topic has been closed for replies.
Correct answer try67

Use this code:

var f1 = this.getField("Text6");

var f2 = this.getField("Text8");

var s = util.printd("m/d/yyyy h:MM tt", new Date());

if (f1.valueAsString=="") f1.value = s;

else f2.value = s;

1 reply

try67
Community Expert
Community Expert
March 17, 2019

You would need to add an if-condition to your code.

If the first field is empty, populate it. If it's not empty, populate the second field.

Known Participant
March 17, 2019

Thank you.  Can you help me with the code?  The first block is Text6 and second block is Text8.  So far this is what I have in will print:

var f = this.getField("Text6");

if(f.valueAsString=="")f.value = util.printd("m/d/yyyy h:MM tt", new Date());

and this is what I have in did print:

var f = this.getField("Text8");

f.value = util.printd("m/d/yyyy h:MM tt", new Date());

I'm assuming that the if-condition would be added to the did print?

try67
Community Expert
Community Expert
March 17, 2019

Sorry, maybe I didn't understand. The first box should be used for the Will Print event and the second for the Did Print?