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
BedrockMission!

Learn More

View all

Sign in to view all badges

Instance Manager - how to reference?

Avatar

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
xrum
Level 3

10-12-2008

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!

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 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

611 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

10-12-2008

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

Avatar

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
xrum
Level 3

10-12-2008

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

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 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

611 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

10-12-2008

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.

Avatar

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
xrum
Level 3

16-12-2008

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

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 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

611 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

16-12-2008

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);

Avatar

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 3
xrum
Level 3

Likes

7 likes

Total Posts

89 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
xrum
Level 3

16-12-2008

yeay! it's working, thanks!



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



Thanks again!