Skip to main content
Participant
April 1, 2021
Question

Help with script for a time stamp

  • April 1, 2021
  • 1 reply
  • 587 views

I currently have a form with script that I made that if you push a button, a timestamp will show up as mmddHHMMSS. I want to add two letters in front of this time stamp based off another field on my form. For example if they choose Redwood for the Billing Location then I want my time stamp to say RM-mmddHHMMSS. If they choose Montevideo for the Billing Location then I want my time stamp to say MO-mmddHHMMSS. My current script is this the first script I ever wrote and I pieced it together from other examples.

My current script is:

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<AcroForm>
//<ACRO_source>Auto ATOL Click:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Auto ATOL Click:Annot1:MouseUp:Action1 ***********/
var f = this.getField("Auto ATOL");
f.value = util.printd("mmddHHMMss", new Date());
//</ACRO_script>
//</AcroForm>

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 1, 2021

Use this code:

 

 

var billingLocation = this.getField("Billing Location").valueAsString;
var prefix = "";
if (billingLocation=="Redwood") prefix = "RM-";
else if (billingLocation=="Montevideo") prefix = "MO-";
// etc.

var f = this.getField("Auto ATOL");
f.value = prefix + util.printd("mmddHHMMss", new Date());

 

Participant
April 2, 2021

This worked perfectly. THANK YOU!!