Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Making a script combining two fields to make a casenumber

Avatar

Level 1

Hello,

My name is Rick and I really need your help.

While building a form that helps end-users report complaints, I'd like my form to automatically make a casenumber by combining two fields.

I've tried figuring scripts out on my own, with the 'help' function, searching forums but no salvation yet.

I look forward to your reaction!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Just for starters, it looks like you have the script in a numericField. Change the type to a textField.

Niall

View solution in original post

5 Replies

Avatar

Level 10

Hi Rick,

LC Designer has two languages: Javascript and FormCalc.

You can use either one for your requirement. FormCalc is handiest as it includes a concatenation function that can join multiple fields into a separate field.

If the two fields are 'fullName' and 'location' the script in the calculate event of the caseNumber field could be:

$ = Concat(fullName, "/", location)

In Javascript it would look like this (also in the calculate event):

this.rawValue = fullName.rawValue + "/" + location.rawValue; 

Either of these should achieve what you want.

Good luck,

Niall

Avatar

Level 1

Thanks a lot for your help! Still, it isn't working properly. The form doesn't execute the script when I send it, leaving te field saying "0". This is my script: this.rawValue = Datum.rawValue + "/" +  Organisatie.rawValue

What would even be better is a calculation which makes a casenumber based on the date plus a number or text like: 08022010001 or 08022010a.

Avatar

Correct answer by
Level 10

Hi,

Just for starters, it looks like you have the script in a numericField. Change the type to a textField.

Niall

Avatar

Level 1

Thanks! That's it!

Can i also add something to the script to provide a random number?

Avatar

Level 10

Hi,

Here is a sample where the reference number is the full date and time, down to the second. https://acrobat.com/#d=7MTJmmhWCVSfQQir3XwxXQ

Here is a sample of a random number generator. It creates a 4-digit random number of a click event, but you can extend this. https://acrobat.com/#d=iVdJ1rAWKPL7qXj8zLs9yg

Good luck,

Niall