Skip to main content
Inspiring
October 25, 2023
Answered

Is it possible to populate a field with data from only one (1) of 10 potential fields?

  • October 25, 2023
  • 1 reply
  • 947 views

If I have 10 text fields and wish to populate a separate text field with data from the first field of the 10 containing data, is there a scripting method that would allow me to do so?  I have been tinkering and clearly have not been successful so thought I'd ask the Subject Matter Experts (SMEs). 

Thanks in advance for any time and assistance!

Very Respectfully,

Charlie   

This topic has been closed for replies.
Correct answer Nesa Nurani

Try something like this, it will populate first field that have value, just change field name to your actual field name:

for(var i=1; i<=10; i++){
if(event.value == ""){
if(this.getField("Text"+i).valueAsString !== "")
event.value = this.getField("Text"+i).value;}}

1 reply

Nesa Nurani
Community Expert
Community Expert
October 25, 2023

Yes, you can use script to do that.

How do you wish to populate the field, automatically as soon as data is entered or via button, checkbox...etc?

What if there are multiple fields that have value, which one should populate field?

 

Inspiring
October 25, 2023

Good day Nesa!  Thank you for responding. 🙂 

Ideally, as soon as the field is populated -- my personal preference -- but there may be a requirement for a button depending on what final direction I'm given.  

Very Respectfully,

Charlie

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 25, 2023

Try something like this, it will populate first field that have value, just change field name to your actual field name:

for(var i=1; i<=10; i++){
if(event.value == ""){
if(this.getField("Text"+i).valueAsString !== "")
event.value = this.getField("Text"+i).value;}}