Help with script for a time stamp

New Here ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

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>

 

TOPICS
How to, JavaScript, PDF forms

Views

89

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

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());

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2021 Apr 02, 2021

Copy link to clipboard

Copied

LATEST

This worked perfectly. THANK YOU!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines