Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Dropdown with two rawValues

DKinsley
Level 9
Level 9

Is it possible to have a dropdown list object with two rawValues?

For example:

John Smith is the diplayed name and the rawValues are his email address and authorized spending limit (5000).

jsmith@emailaddress.com, 5000

If yes, I want the 5000 dollars to appear in textfield1 and the email address in textfield2. How do I access them?

1 Accepted Solution
Jono_Moore
Correct answer by
Level 10
Level 10

You can think of an array as kind of like using instance numbers. The split() method is putting each value into it's own "slot" in the array. So to pull information out you just need to specify the slot you want to reference.

In your case you can do away with the loop as you only have two values and just write them out explicitly.

var sElements = this.rawValue.split(",");

email.rawValue = sElements[0]; //first value

dollar.rawValue = sElements[1]; //second value

View solution in original post

12 Replies
DKinsley
Level 9
Level 9

The part I do not understand is how to split the array out to particular existing textfields.

Script Section.jpg

Jono_Moore
Correct answer by
Level 10
Level 10

You can think of an array as kind of like using instance numbers. The split() method is putting each value into it's own "slot" in the array. So to pull information out you just need to specify the slot you want to reference.

In your case you can do away with the loop as you only have two values and just write them out explicitly.

var sElements = this.rawValue.split(",");

email.rawValue = sElements[0]; //first value

dollar.rawValue = sElements[1]; //second value

View solution in original post

DKinsley
Level 9
Level 9

Thank you so much, that works great! Now I just have to figure out how to create my list in Excel with the values seperated by commas.

Thanks for your help with this.

DKinsley
Level 9
Level 9

How many vlaues can you have before you have to use the "loop" script?

Thanks

Jono_Moore
Level 10
Level 10

As long as your spreadsheet is set up with the values going across the columns you can just Save As a CSV (comma separated values) file.

Jono_Moore
Level 10
Level 10

Doesn't really matter. In Niall's sample he was adding instances and had multiple different values for each item so the loop made sense especially as there were differing amounts of values - so using the array's .length on a given record gives you the correct number of fields.

Really just depends on what you're trying to do, if a loop makes it easier go for it!

DKinsley
Level 9
Level 9

I saved the Excel file as a CSV but when I copy and paste into LiveCycle, I get an error that it can not interpret the file. I am using the clipboard button in the dropdown object. I tried pasting the CSV data to Notebook, but it does not show the commas. What am I doing wrong?

Jono_Moore
Level 10
Level 10

Sounds like you are trying to copy/paste from Excel. You need to open the CSV file in a text editor and copy/paste from there.

DKinsley
Level 9
Level 9

Yes, that was what I was doing. When I open the csv file in the text editor, I get what I need but there are a ton of unneeded commas like:

JohnSmith,50,jsmith@email.com,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Is there a way to prevent them? Or can I just paste them in?

Jono_Moore
Level 10
Level 10

You should only get the commas you need, unless there is data in the other columns?

I use CSV files quite a lot for mail-merge applications and sometimes get extras rows at the bottom but never seen a bunch of commas like that.

Maybe try selecting the three columns of data and paste into a new spreadsheet and save as CSV. The only thing I can think of is if you have extra columns with titles that might be causing it - usually with CSV the first row is used for naming the columns.

DKinsley
Level 9
Level 9

Yes, that fixed it.

Thanks Juno!

-Don