Skip to main content
Known Participant
July 9, 2020
Question

Data selected in Dropdown fields is resetting upon opening the form due to format script..

  • July 9, 2020
  • 1 reply
  • 284 views

I have recently added the following format script to automatically populate the dropdown fields when text is entered in certain fields: 

 

var emailList = [" "];

if(event.value){emailList.push(event.value)};

if(this.getField("EmailAddress2").value) {emailList.push([this.getField("EmailAddress2").value]);} 

if(this.getField("EmailAddress3").value) {emailList.push([this.getField("EmailAddress3").value]);}

this.getField("PortfolioCorrespondenceEmail1").setItems(emailList);

 

However, I believe that this code is executing upon opening the form, meaning that any values in the dropdown list that were previously saved are removed due to this code running again and resetting the dropdown list to the initial value which is " ".

 

I am wondering how I can prevent this happening so the format script doesn't run upon the form opening and only runs when there is a change in that event field? As at the moment it is giving the impression that there was no data entered in the dropdown field, which isn't the case. 

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
July 9, 2020

Use the script as validation of the field.