These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

setItems() not working in Reader 9.0.0

ADB
Registered: Nov 28 2011
Posts: 20

I have a form where I populate a combo-box using document JavaScript. This form was developed using Acrobat X Pro. I used the method setItems() for this purpose. Now when I open the form in Reader 9.0 but the method setItems() does not work. I replaced the method with insertItemAt() which does work in Reader 9.0. This method accepts 3 parameters,
 
cmb.insertItemAt(valueString, exportValue, index)
 
The problem is if I use anything except a string in double-quotes("string") this method does not work. I tried using all the following options,
 
//This works. -1 is for adding the item at the end of list.
cmb.insertItemAt("AddThis", "AddThis", -1);
cmb.insertItemAt("AddThis", 0, -1);
 
//This does not work.
var str = "AddThis";
cmb.insertItemAt(str.toString(), 0, -1);
cmb.insertItemAt(String(str), 0, -1);
cmb.insertItemAt(str.valueof(), 0, -1);
cmb.insertItemAt(myArr[0], 0, -1)//Tried all above with array also.
 
Can anyone please help me out. Any help is appreciated. Thank you.

My Product Information:
Reader 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
I just tested with Reader 9.4.4 and setItems worked just fine. Is it just Reader 9.0 that's not working for you? What error message are you getting in the console, both for setItems and insertItemAt?


ADB
Registered: Nov 28 2011
Posts: 20
George_Johnson wrote:
I just tested with Reader 9.4.4 and setItems worked just fine. Is it just Reader 9.0 that's not working for you? What error message are you getting in the console, both for setItems and insertItemAt?
I am new to this environment and I dont know how to use the debugger in Reader. Can you please help me? Thank you.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
In Reader select: Edit -- Preferences -- JavaScript -- JavaScript Debugger -- Show console on errors and messages

and the console will get displayed if the code generates an error.
ADB
Registered: Nov 28 2011
Posts: 20
Thank you very much George for letting know how to enable the debugger. I get the following errors,

When setItems() is called with an array:

Exception in line 182 of function SetValues, script Document-Level:MainScript
Line: 70: Code: -36(0xffdc): Not implemented

When insertItemAt() is called with arguments(myarray[0], myarray[0], -1)

arrOptions has no properties
183:0Exception in line 183 of function SetValues, script Document-Level:MainScript
Line: 70: Code: -36(0xffdc): Not implemented

Hope this clarifies stuff for you.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can't add two items with the same name, even if they have different export values. How is the user supposed to know which is which?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
try67 wrote:
You can't add two items with the same name, even if they have different export values. How is the user supposed to know which is which?
The errors that I have reported are from 2 different runs. Once with setItems() and then I blocked setItems() and tried with insertItemAt().


try67
Expert
Registered: Oct 30 2008
Posts: 2398
But you're still trying to do the same... adding two separate items with the same name, which is not possible.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
try67 wrote:
But you're still trying to do the same... adding two separate items with the same name, which is not possible.
where have I done that?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Well, you did it with insertItemAt... I guess I thought you tried the same with setItems. Maybe you should post the full code you're using.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
ADB wrote:
When insertItemAt() is called with arguments(myarray[0], myarray[0], -1)

arrOptions has no properties
183:0Exception in line 183 of function SetValues, script Document-Level:MainScript
Line: 70: Code: -36(0xffdc): Not implemented


Are you refering to this piece of code. IF yes, then my bad. What i meant by this is that I made ONLY 1 call to insertItemAt as

insertItemAt(myarray[0], myarray[0], -1)
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I meant this:
cmb.insertItemAt("AddThis", "AddThis", -1);
cmb.insertItemAt("AddThis", 0, -1);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
Quote:
//This works. -1 is for adding the item at the end of list.
cmb.insertItemAt("AddThis", "AddThis", -1);
cmb.insertItemAt("AddThis", 0, -1);


I dont think that is the problem because I have tested that code and it works fine(as I have reported above it). The problem I think arises when I try to use arrays. Even though the arrays work fine in Acrobat Pro 10.1.1 my Reader 9.0 seems to have problems with arrays.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Does your file have form rights for Reader?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
I am sorry again but can you please tell me how to check/enable that?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
In Acrobat (9 Pro) you enable it from Advanced - Enable Usage Rights in Adobe Reader...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
I dont have Acrobat (9 Pro) I have Reader 9.0 and now I see that instead of an array if i use

var index= ["One","Two"];
cmb.insertItemAt(index[0], index[0], -1)

the code works fine. DOes this give you any idea about the problem? I am really sorry that I am bugging you so much.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Not really. Like I said, post the entire (relevant) code you're using, including any error messages.
It's not possible to debug snippets of code without the full context.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ADB
Registered: Nov 28 2011
Posts: 20
Really sorry but it looks like I am going to have to go with whatever works at this instant. Thank you very much for all the help and the time you put in.