instanceManager subform instance referencing?

Avatar

19-01-2009

Seems like you cant use a variable to call an instance?

Asuming I have x instances of .detail1 below & need to do something to them all:



var agendas = 0;

xfa.resolveNode("form1.Sheet1.detail1[agenda].Button2").presence="invisible";



if I replace the [agenda] with 0 it works. I'm trying to make a for loop that crawls through a number of instances with no luck. Any thoughts?



replace with an [*] and acrobat crashes!

Replies

Avatar

20-01-2009

Should work, has done it myself a lots of times... but remember to but agenda in correct syntax.

var agenda = 0;

xfa.resolveNode("form1.Sheet1.detail1["+agenda+"].Button2").presence = "invisible";

Avatar

20-01-2009

aha - that's a syntax I've not seen before. thanks. What are the + marks for & why the quotes?



thanks,

-jamie

Avatar

20-01-2009

follow up: first time I've tried to write a FOR loop. Can you spot my mistake?



for (var i=0; i<=Sheet1.formType.body2.ExpandingMemo.details.detail1.instanceManager.count; i++;)

{

xfa.resolveNode("Sheet1.formType.body2.ExpandingMemo.details.detail1["+i+"].Button2").presence="invisible";

};



well, the smiley face is supposed to be a ; and a )



Oh - nevermind I found it - the extra ; after the i++ was the problem.

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

20-01-2009

FYI - The syntax you are unfamiliar with is a bit tricky at first. The resolveNode function evaluates a string and tries to see if there is a form object to match it. When your string is...



"Form.subForm.Table.Row[x].Cell1"



The script is looking for a Row with an index of "x", which technically does not exist. By breaking the string and concatenating in the variable (at runtime, whatever value that variable contains - in your case, the loop increment) to that string. LiveCycle will evaluate it as such.



Hope that helped explain it a little.



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com

Avatar

20-01-2009

So, then the follow-up follow-up question:



I have two of these FOR-Loops in a row, each of which works independantly, but when I have the two of them on the "Click" event of the button they dont work.



Any guesses why only the first one runs?



for (var i=0; i<=form1.Sheet1.formType.body2.ExpandingMemo.details.detail1.instanceManager.count; i++){

xfa.resolveNode("form1.Sheet1.formType.body2.ExpandingMemo.details.detail1["+i+"].Button2").presence="invisible"

};



for (var k=0; k<=form1.Sheet1.ImageSection.detail.instanceManager.count; k++){

xfa.resolveNode("form1.Sheet1.ImageSection.detail["+k+"].deleteButton").presence="invisible"

};

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

20-01-2009

Any errors in the javscript console?

Avatar

20-01-2009

No obvious syntax error in your code (although it's not the easiest to find always). But why do you put the ; after the closing bracket } ?

Usually these kind of errors happen when your code generates an error in the first loop, thereby Pauls question. Since you don't seem all familiar with the Designer/pdf development process, check if you have enabled the option to show javascript console on errors in the Reader. It's a bit hidden in the settings for Acrobat Reader but it helps out a lot in these cases to see if something goes wrong.

Avatar

20-01-2009

Whoa - that's the console I kept looking for in Livecycle...



23:XFA:form1[0]:#pageSet[0]:Page1[0]:logoStuff[0]:calculate

xfa.resolveNode("form1.Sheet1.formType.body2.ExpandingMemo.details.detail1[" + i + "].Button2") has no properties

7:XFA:form1[0]:Sheet1[0]:formOptions[0]:lockdown[0]:click



So it is the first loop causing the error, but its doing what its supposed to first...



I tried again without the semi-colon ; after the brackets. No change. Was just copying what I saw in the Order Form sample file...