Generate an E-mail Address
When ordering an ID card, users need to fill in their first name and last name. These are stored in the variables firstname and lastname. The e-mail address needs to be created automatically using these two variables. It consists of the first digit of the first name, a period and then the last name. The '@domain' part of the e-mail address is added using a suffix. All characters must be lower case. If the last name contains spaces these must be converted to a period.
On the ID card, a variable named email is used with type set to 'Calculated Field'. The 'Value' action below is used for this email variable. It creates a temporary variable named tmpEmail, copies the first digit of firstname and appends it with a period and the lastname variable. Next, all spaces in tmpEmail are replaced by periods and all characters are converted to lower case. The result is then returned to the email variable.
Action type: Value
Variable type: Calculated Field
Action code:
1 declare string tmpEmail =
2 set local tmpEmail = stringFunctions subString string variable firstname value startIndex number 0
length number 1
3 set local tmpEmail = local tempEmail & string . & variable lastname value
4 set local tmpEmail = stringFunctions replace string local tmpEmail
find string <space>
replace string .
caseSensitive false
5 set local tmpEmail = stringFunctions toLowerCase string local tmpEmail
6 return local tmpEmail
doc. version 6.0.4