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

Community Beginner ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

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. 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, PDF forms

Views

31

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

Use the script as validation of the field.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines