Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Problems to concatenate two text fields (one field is blank)

venturacelia
Level 1
Level 1

Hi everyone,

I'm having problems to concatenate two text fields.

I found one way to concatenate the two text fields (this.rawValue = line1.value +  " " + line2.value;), but it doesn't work if the 2snf field I am trying to combine is blank.

The only way they seems to work is if I setup 2 invisible fields at the top of my form (1 for line1 and another one for line2) and then use the below line of code:

if(xfa.record.line2.value != null){

                this.rawValue = xfa.record.line1.value;

} else {

                this.rawValue = xfa.record.line1.value +  " " + xfa.record.line2.value;;

}

As I am new to LiveCycle and my knowledge of javascript is quite limited, I was wondering if someone could advise if there is a better way to do it.

What am I missing?

thanks

4 Replies
Magus069
Level 10
Level 10

Hi there,

If a value is null while trying to concatenate it with another value it will always return an error.

To be able to make it work as if it should be blank instead of null you will have to replace the value by quotations mark to make it work properly.

Hope this help!

venturacelia
Level 1
Level 1

Hi Magus069.

Thanks for your reply.

I tried this but I'm still getting a blank value.

If one of the fields are blank, I still need whatever is on the other

field.

E.g.:

Line 1 is address line 1

Line 2 is address line 2

If address line 2 is blank, I still need the address line 1 field to be

populated on my form.

Any suggestions?

Thanks

Magus069
Level 10
Level 10

is Line1 and Line2 are textfields?

if yes, instead of using value, you should use rawValue

venturacelia
Level 1
Level 1

Hi.

Yes, both are text fields.

I tried with rawValue but I'm still getting the same result.

Nothing is populated on the form.