Or is there some initialize event I can use that is guaranteed to run first, before the depth-first initialization process begins?
Here's a better description of my scenario (it's not the best example, but it works). I have XML input, and the XML contains a list of cars. Each car element has several child elements, one of which is hasCruiseControl. The possible values for hasCruiseControl are yes, maybe, and no.
I need to display a table of all the cars. In one of the cells, I need to display the value of hasCruiseControl. I also need to display a footnote next to the value, and the corresponding footnote text at the bottom of the page. Here's where it gets tricky. If all cars in the XML list have hasCruiseControl=yes or hasCruiseControl=no, then I only need to show 1 footnote, and that footnote's number is (3). If all the cars in the list have hasCruiseControl=maybe or hasCruiseControl=no, then I only need to show 1 footnote, and that footnote's number is also (3), but the text at the bottom of the page for footnote (3) will be different. If some of the cars in the list have hasCruiseControl=yes and some have hasCruiseControl=maybe, then I need to show 2 footnotes, whose numbers will be (3) and (4). (hasCruiseControl=no has no footnote; it is just yes and maybe that generate footnotes.)
So I need to be able to evaluate ALL of the XML data prior to an initialize event for an individual table cell, because I need to know the cardinality of the yes's and the maybe's beforehand. I'd prefer not to have to loop through all my XML data every time for each cell.
So lets try a different approach. Let the form get driven by the data (layoutis complete) then just before we hand the form to the user we check for your crusie control conditions and adk=just the footnote text accordingly. You could see how many Car subforms were creatded then test the has cruise control for each and then do what needs to be done.
This way you are only executing the code once. You woudl put the code on the DocReady event of the root node of the heirarchy.
That sounds like what I've been looking for. Once the layout is complete, will I be able to show/hide objects as needed? As I mentioned above, I might be showing 2 footnotes, or 1, or 0, depending on if there is yes+maybe, yes or maybe, or no only.
First you would have to get a count of the number of subforms. You can use the subformname.instanceManager.count. Now that you know how many that you have you can use that value for the upper limit of your counter.
To address each individual field you will require an occurance number and that is on the subform container of the field. So if you have TextField1 in subform1 on Page1 in form1 your expression woudl look like this:
form1.Page1.subform1[occurancenumber].TextField1.property or method that you want
Now the tricky part. Javascrit does not like square brackets, so you have to use the xfaresolveNode("string representing SOM Expression").
So if you wanted the rawValue and you were in a loop where i is the counter value your expresion woudl look like this:
xfa.resolveNode("form1.Page1.subform1[" + i + "]").TextField1.rawValue