Copy link to clipboard
Copied
Hi,
I am trying to shorten the script below which allows me to import the same list of items into multiple drop down box fields. I would like to be able to list the fields in a row using a single command instead of executing the complete command for each field. The script does work but I would like to streamline as it populates a large number of fields.
var aOptions = [
"One",
"Two",
"Three"
];
this.getField("Parts 1").setItems(aOptions);this.getField("Parts 2").setItems(aOptions);this.getField("Parts 3").setItems(aOptions);
You can do it using an array, like this:
var aOptions = [ "One", "Two", "Three" ];
var fields = ["Parts 1", "Parts 2"];
for (var i in fields) this.getField(fields).setItems(aOptions);
Copy link to clipboard
Copied
You can do it using an array, like this:
var aOptions = [ "One", "Two", "Three" ];
var fields = ["Parts 1", "Parts 2"];
for (var i in fields) this.getField(fields).setItems(aOptions);
Copy link to clipboard
Copied
Thanks for the prompt response, the script worked fantastically!
I put together an excel spreadsheet which combines a parts description and 2 part numbers into a single column and also auto inserts the script quotation marks and commas for each item making scripting a lot easier in the future.
For anyone interested the following formula in excel allows you combine 3 columns in excel into a single column and also automatically inserts the required javascript quotation marks and commas. The additional / between columns is to separate the description and part numbers in the drop down box text. In this example the formula is applied to column D in the excel spreadsheet which is the combined column I cut and paste into the document level javascript.
=CONCATENATE("""",A2," / ",B2," / ",C2,""",")
Copy link to clipboard
Copied
There is a concatenate method for the String object that can perform the Excel macro CONCATENATE action.
event.value = "".concat('"', this.getField("A2").value, " / ", this.getField("B2").value, " / ", this.getField("C2").value, "\",")
One could also create a "smart" concatenate function the only applies the separator character when the input values are not null strings.
Copy link to clipboard
Copied
Where does this script go? I get errors no matter where I place it.
Copy link to clipboard
Copied
With the Action Wizard you can create an action for this.