Copy link to clipboard
Copied
Hi All,
I am creating a form and doing some javascripting in the back end to customise the form to our particular needs.
One section of the form is a drop down. Depending on the selection of the drop down, (labelled "Your_Service_Agreement"), I need it to auto-populate data from already existing fields into the following field (Labelled "Service_Agreement_Name").
The fields that will have the data that I need to transfer are "First_Name", "Last_Name" and "Nominee_Full_Name".
Any advice is greatly appreciated!
Copy link to clipboard
Copied
Use this:
switch (event.value){
case "I,":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").valueAsString+" "+this.getField("Last_Name").valueAsString;
break;
case "My plan nominee,":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}
Copy link to clipboard
Copied
I assume choices in dropdown are (First Name,Last Name and Full Name) if not, change script to reflect your actual choices.
Use script as validation of dropdown field:
switch (event.value){
case "First Name":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").value;
break;
case "Last Name":
this.getField("Service_Agreement_Name").value = this.getField("Last_Name").value;
break;
case "Full Name":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}
Copy link to clipboard
Copied
Thanks for this Nesa,
So it's a bit of a strange one...
The options in the drop down are "I," or "My plan nominee,"
if "I," is selected in the drop down, First_Name and Last_Name need to be pulled. These are two seperate data fields, can these be merged into a single field upon calling?
if "My plan nominee," is selected, then Nominee_Full_Name needs to be pulled. Could you help with this?
Copy link to clipboard
Copied
Use this:
switch (event.value){
case "I,":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").valueAsString+" "+this.getField("Last_Name").valueAsString;
break;
case "My plan nominee,":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}
Copy link to clipboard
Copied
You are an absolute angel! Thank you so much!!!
Copy link to clipboard
Copied
Is there a way to allow for multiple lines in the auto-population?
Meaning, based on what's selected in the drop-down, I want a list of instructions to auto-populate in another field. I'd like to start a new line with each step instead of paragraph form.
Copy link to clipboard
Copied
Use \n for new line.
Copy link to clipboard
Copied
It's giving me an error message.
Copy link to clipboard
Copied
Text needs to be inside quotes. Also, you don't need a semicolon after each line of text.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now