Skip to main content
kenneth kam chuh21426993
Known Participant
April 27, 2023
Answered

Date to ddmmyyyy format with extra added text

  • April 27, 2023
  • 2 replies
  • 1593 views

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? 

This topic has been closed for replies.
Correct answer Nesa Nurani

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.

2 replies

maxwithdax
Community Expert
Community Expert
April 27, 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?

 

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
April 27, 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.

kenneth kam chuh21426993
Known Participant
May 4, 2023

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