Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Jump to first page of added instances

Avatar

Level 7

Hello,

I have a form where there is a button that allows the user to add a new set of the first four pages of the form. The cursor automatically based on the script sets the focus on the first field in the first page of the new set of 4 pages. That all works great. This allows the end user to add as many sets of 4 pages as needed.

Now the business owner of the form, wants to be able to jump to the first page of any of the added sets. I know how to script to jump to a specific page when there are a set number of pages, but I don't know how to jump to the first page of a set that hasn't been added yet. I'd appreciate any help that's offered!

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

Ahh I think I already found out what you want to do.

Use this script for the addNestedTerm button.

_pages1_3.addInstance(1)

xfa.host.setFocus(xfa.resolveNode("pages1_3[" + (_pages1_3.count - 1) + "]").spot.TextField9.somExpression);

To set focus from the Go to next nested term button use this script.

var i = this.parent.parent.index;

if (i < _pages1_3.count - 1) {

          xfa.host.setFocus(xfa.resolveNode("pages1_3[" + (i + 1) + "]").spot.TextField9.somExpression);

}

hope this helps.

View solution in original post

14 Replies

Avatar

Level 10

This is possible with a counter of the repeated objects.

Here's an example.

Replace "subform1" with the name or Som expression of your subform.

xfa.host.setFocus(subform1[xfa.resolveNodes("subform1[*]").length - 1].textField1.somExpression);

Avatar

Level 7

Thanks for your quick response.

I put this script in the click event of a button I created to let the user click the button to jump to the first page of the next set of pages. I replaced the subform1 for the name of the subform and I changed the textField1 to the name of the field where the cursor should appear. But I'm not sure what to put for somExpression in your example.

Thanks,

MDawn

Avatar

Level 10

Hi,

somExpression is a scripting property that returns the SOM expression of the object written in front of the property.

subform1[xfa.resolveNodes("subform1[*]").length - 1].textField1.somExpression returns a SOM expression like form1[0].page[0].subform1[3].textField1[0]

Avatar

Level 7

Could I share my form with you? I'm not able to get this to work.

Thanks,

MDawn

Avatar

Level 10

Sure,

upload the form somewhere and post a link here.

Avatar

Level 7

Here's the link:

https://files.acrobat.com/folder/348612a4-e8fb-4a5d-a860-e97789f05228

It's called the True Up Checklist. I put the script in question in the Go to next Nested Term button seen on page 1.

Thanks,

MDawn

Avatar

Level 10

I don't have access to the file, make sure you shared it. ;-)

Avatar

Level 7

Now is says 'shared'. Will it be the same link?

mdawn

Avatar

Level 10

You said a button will new instances of the 4 pages. Which button is it?

Avatar

Level 7

The button that adds the new  instance is on page 5. It's called Add Nested Term. The script there works fine.

The button to jump to the first page of an added instance is on page 1 and then on the first page of each added instance. It's called 'Go to Next Nested Term.'

Thanks,

MDawn

Avatar

Correct answer by
Level 10

Ahh I think I already found out what you want to do.

Use this script for the addNestedTerm button.

_pages1_3.addInstance(1)

xfa.host.setFocus(xfa.resolveNode("pages1_3[" + (_pages1_3.count - 1) + "]").spot.TextField9.somExpression);

To set focus from the Go to next nested term button use this script.

var i = this.parent.parent.index;

if (i < _pages1_3.count - 1) {

          xfa.host.setFocus(xfa.resolveNode("pages1_3[" + (i + 1) + "]").spot.TextField9.somExpression);

}

hope this helps.

Avatar

Level 7

Great! That works. Now I need to study them and figure out why they worked.

Thank you,

MDawn

Avatar

Level 7

Sorry to keep bothering you. Is there a way to change the script for another button that would take the user to the previous nested term?

Thanks,

MDawn