• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Combine multiple field entries into one field with "-" separations

New Here ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

I have three specific fields in a PDF form that I would like to combine into a single field (that is then used for filenaming later on).

 

Currently I have the three field appearing as a string of numbers, but I would like a "-" (dash) between each field (so the filename is easier to decode).

 

Currently I have the following:

Run custom validation script:

event.value = event.value.replace(/\D/g, "");

 

Custom calculation script:

var s = this.getField("exchange_date").valueAsString + this.getField("part_origin").valueAsString + this.getField("kr_art_nr").valueAsString;

event.value = s.replace(/^, |, $/g, "");

 

but with this it correctly removes the '/" from between the yyyy/mm/dd to present it correctly as yyyymmdd, but I would like everything to appear as follows:

 

exchange_date-part_origin-kr_art_nr

20240529-123456-987654

 

Been battling this for a few hours and cannot seem to find the trick to make this work!

 

Much appreciate your help.

TOPICS
Create PDFs , How to , PDF , PDF forms

Views

73

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

correct answers 1 Correct answer

Community Expert , May 29, 2024 May 29, 2024

Remove the validation script and use this for the calculation:

 

var s1 = this.getField("exchange_date").valueAsString.replace(/\D/g, "");
var s2 = this.getField("part_origin").valueAsString.replace(/\D/g, "");
var s3 = this.getField("kr_art_nr").valueAsString.replace(/\D/g, "");

event.value = s1 + "-" + s2 + "-" + s3;

Votes

Translate

Translate
Community Expert ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

LATEST

Remove the validation script and use this for the calculation:

 

var s1 = this.getField("exchange_date").valueAsString.replace(/\D/g, "");
var s2 = this.getField("part_origin").valueAsString.replace(/\D/g, "");
var s3 = this.getField("kr_art_nr").valueAsString.replace(/\D/g, "");

event.value = s1 + "-" + s2 + "-" + s3;

Votes

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