Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Pulling multiple variables into a single line?

Avatar

Level 2

There really seems like an easy fix to this, but I'm just not finding it on my own here.

Here's my setup: I've got four variables that are pulling data from our system: Customer Address, City, State, and Zip - for some silly reason we do not have a single variable for all of these combined.

As such, I'm trying to include all of thee variables in one field, this is what I've got set up as of now:

Four Invisible fields that pull this data into the form individually

One field titled "Customer_Address Line"

A formcalc line with the following data:

Customer_Address_Line = CUSTOMER_ADDRESS + CUSTOMER_CITY + CUSTOMER_CATE + CUSTOMER_ZIPCODE

I've tried various different methods to try to get this to print correctly but in the end I've only managed to confuse myself.

The best I can get is only the zipcode to print.

What am I missing???

Any help would be GREATLY appreciated! Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

To create a single string use the concat method of FormCalc in the layoutReady:Event of your field.

$ = concat(CUSTOMER_ADDRESS, " ",CUSTOMER_CITY, " ",CUSTOMER_CATE, " ",CUSTOMER_ZIPCODE)

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

To create a single string use the concat method of FormCalc in the layoutReady:Event of your field.

$ = concat(CUSTOMER_ADDRESS, " ",CUSTOMER_CITY, " ",CUSTOMER_CATE, " ",CUSTOMER_ZIPCODE)

Avatar

Former Community Member

Radzmar is right .....you  need the concat function to add strings together in FormCalc. Your technique is used with Javascript.

The object names are case sensitive so make sure you have the right case. Also you can put yor cursor in the script editor wher you want the reference to the object placed, then hold down the ctrl key and move your mouse to the desired field (the cursor will change to a V). Now click on the mouse and a reference will be placed in the script editor.

Hope that helps

Paul

Avatar

Level 2

Thanks guys, this saved the day! I had been playing with concat for a bit but was only showing the name of the variable or getting errors. Went back to what you had said, changed the calculations to be done at both client and server, and it works like a charm.