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

Instance Manager - how to reference?

xrum
Level 4
Level 4
hi 🙂



i have a dynamic subform, which i am adding and deleting (users).



the subform has such information as name, address, phone etc.



is there a way for me to reference last (or second, or third) instance of that subform, and get the last address that has been added/deleted?



i can't seem to find a way to do it.



Thanks!
6 Replies
pguerett
Level 10
Level 10
The innstanceManager has a count property which will give you how many occurances of that subform that exists. Also if you know which occurance that you want to look at you can address the field by using the full somExpression and giving the occurance number on the subform. Something like this:



form1.page1.dynamicSubformName[1].address.rawValue



Note that the [] will cause a problem in Javascript (they are used to indicate array elements) hence you need this syntax in javascript:



xfa.resolveNode("form1.page1.dynamicSubformName[1]").address.rawValue



Depending on where your code is runnning, if it is on a field level event you can get the occurance that the object is in by using this.parent.index



Hope this helps
xrum
Level 4
Level 4
thanks!



when I do this:



xfa.resolveNode("form1.page1.dynamicSubformName[1]").address.rawValue



it works, but when i put in the count, instaed of 1



xfa.resolveNode("form1.page1.dynamicSubformName[dynamicSubFormName.instanceManager.count]").address.rawValue



i get "Malformed SOM expression" error....
pguerett
Level 10
Level 10
The quotes signify a string. count needs to be a calculated value so you woudl do smething like this:



xfa.resolveNode("form1.page1.dynamicSubFormName[" + count + "]").address.rawValue



I assume count is a variable that contains the occurance that you want to test.
xrum
Level 4
Level 4
that is correct....



but i still don't understand what i am doing wrong.....



this is my code now:



var myCount = userSub.instanceManager.count-1;



app.alert(xfa.resolveNode("form1.formPage.mainSub.userSub[myCount]").userName.rawValue);



i'm still getting the "Malformed SOM expression" error....
pguerett
Level 10
Level 10
The issue is that myCount is not getting resolved beacuse it is inside of the quotes and is being interpretted as a string. I believe the expression should be:



app.alert(xfa.resolveNode("form1.formPage.mainSub.userSub[" + myCount + "]").userName.rawValue);
xrum
Level 4
Level 4
yeay! it's working, thanks!



sorry, i didn't realize that " + myCount + " was the exact code i was to use 🙂



Thanks again!