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

Date to ddmmyyyy format with extra added text

Explorer ,
Apr 26, 2023 Apr 26, 2023

Hi 

My scenario is this. I am making batches of medicine - lets call it MED 

I can make multiple batches per day (i.e. batch 1, 2, 3) 

I would like an identifier to identify which batch of MED it is.

I want the user to select the date of production in one cell (e.g. 27/04/2023) and automatically fills the other cell with the batch number in the format of (20230427-MED-n) where n is 1,2,3 and can be edited by the user. 

Is this possible? 

TOPICS
JavaScript , PDF forms
1.4K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 26, 2023 Apr 26, 2023

Use something like this as 'Validate' script in 'Date' field:

var str = event.value;
var s = str.split("/");
if(event.value)
this.getField("Text2").value = s[2]+s[1]+s[0]+"-MED-n";
else
this.getField("Text2").value = "";

Just change "Text2" to the name of the field where you want to show that text.

View solution in original post

Translate
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
Community Expert ,
Apr 26, 2023 Apr 26, 2023

Use something like this as 'Validate' script in 'Date' field:

var str = event.value;
var s = str.split("/");
if(event.value)
this.getField("Text2").value = s[2]+s[1]+s[0]+"-MED-n";
else
this.getField("Text2").value = "";

Just change "Text2" to the name of the field where you want to show that text.

Translate
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
Explorer ,
May 03, 2023 May 03, 2023
LATEST

Thanks Nesa. You're amazing! Saved me once more!

Translate
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
Community Expert ,
Apr 26, 2023 Apr 26, 2023

It would be possible but you would need to enlist the help of a javascript author to make it happen. You would need to consider how the 1,2,3 are differentiated. 3 different files?

 

Translate
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