Highlighted

instanceManager subform instance referencing?

Avatar

Guest

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

Highlighted

Avatar

Guest

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";
Highlighted
Highlighted

Avatar

Guest

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.
Highlighted

Ryan_Lunka

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
Highlighted

Avatar

Guest

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"

};
Highlighted

Avatar

Guest

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.
Highlighted

Avatar

Guest

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...