Skip to main content
Participating Frequently
February 7, 2019
Answered

How to Combine data from two text fields into a third

  • February 7, 2019
  • 2 replies
  • 1088 views

I have text information in three separate fields that I need to combine into one output on a second sheet.

It's basically pulling three paragraphs into one text field.

Anyone want to throw some magic Java at it?

This topic has been closed for replies.
Correct answer try67

I meant three text fields


You can use this code as the custom calculation script of the field with the combined values:

var fieldNames = ["SITUATION", "UPDATE1", "UPDATE2"];

var values = [];

for (var i in fieldNames)

    values.push(this.getField(fieldNames).valueAsString);

event.value = values.join("\n\n");

2 replies

Legend
February 7, 2019

Thanks for the info. You can tell it's a while since I wrote one...

Participating Frequently
February 7, 2019

Thank you so much! That worked like a charm.

Inspiring
February 7, 2019

It would be helpful if you provided more details regarding how you want to combine the strings. For example, a common thing to do is separate the strings with spaces, but you may want to use a carriage return/linefeed instead, or something else. It would also help if you included the field names involved.

Participating Frequently
February 7, 2019

Hi George,

Thanks for the help!

The two text fields are SITUATION, UPDATE1 and UPDATE2. They are multi-line text fields that have paragraphs in them and they would need to be separated by carriage returns. The source field data starts with a double space, like a paragraph indent, if that makes a difference.

What I'm after is pulling gentext data into a formal memorandum format.

Participating Frequently
February 7, 2019

I meant three text fields