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

Multiple Variable Scripting - Not sure how to write script in FormCalc or JavaScript - Using LiveCycle ES2

Avatar

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
deliashea
Level 1

11-01-2016

Good afternoon. I am designing a form, and am running into issues on how to create a concatenated field. I have multiple text fields for entering comments throughout the form (TextField1, TextField2, etc.). What I am trying to do is set up an additional calculated field that will display all of the comments listed elsewhere in the document.

Here is the rub - I want each of these to start on a new line, and I don't want a blank line if no comment was left.

I tried using variables (var), but don't know how to set them up to be conditional. What I tried was:

if (TextField1.isNull) then var a = "" else var b = /n + TextField1.rawValue

if (TextField2.isNull) then var b = "" else var b = /n + TextField2.rawValue

$.rawValue = Concat (a, b)

This is in FC because I am even worse with JS, but am willing to learn. Needless to say, there are many more than 2 TextFields - this is just a jumping off point, and I believe the script should work the same no matter the number of variables introduced. If there is anyone who could please lend a hand, I would greatly appreciate it.

Cheers,

Brock

Accepted Solutions (0)

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
deliashea
Level 1

11-01-2016

Because I thought you were supposed to. I should have mentioned - I am not a programmer. I am a technical writer.

I treated the "endif" like a closing parens. I did try removing the "endif" and it no longer told me that accessor 'a' is unknown. However, now I get a syntax error. Here is what I have:

if (TextField1.isNull) then var a = "" else var a = "\n" + TextField1.rawValue

if (TextField2.isNull) then var b = "" else var b = "\n" + TextField2.rawValue

$.rawValue = Concat (a, b)

Error: syntax error near token ')' on line 6, column 0.

There is no line 6. There is also no column 0...

*bangs head against wall*

Avatar

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
Test_Screen_Nam
Level 1

11-01-2016

(Sorry, I see there is an endif in formcalc. But I've never used it, so I don't know further.

Avatar

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
Test_Screen_Nam
Level 1

11-01-2016

Why endif?

Avatar

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
deliashea
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
deliashea
Level 1

11-01-2016

Thank you. Tried the following:

if (TextField1.isNull) then var a = "" else var a = "\n" + TextField1.rawValue endif

if (TextField2.isNull) then var b = "" else var b = "\n" + TextField2.rawValue endif

$.rawValue = Concat (a, b)

Received the following error: Error: accessor 'a' is unknown.

Avatar

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
Test_Screen_Nam
Level 1

Likes

2 likes

Total Posts

44 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
Test_Screen_Nam
Level 1

11-01-2016

If you want a string containing a new line it is "\n"  - backslash, not forward slash, in double quotes.

Avatar

Avatar
Boost 5
Level 2
try67
Level 2

Likes

14 likes

Total Posts

120 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 2
try67
Level 2

Likes

14 likes

Total Posts

120 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 1
View profile
try67
Level 2

11-01-2016

[Question moved to the LCD forum]