Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

setFocus error (Need to find an Anchor)

Avatar

Level 7

Hi All,

I'm using formCalc.

I can't seem to successfully setFocus on any object in a set of 15 repeating subforms. It is not a repeating subform in the binding tab, however--just in name only, for purposes of a for/do loop. That's because there are a couple of differently named subforms scattered in between some of the repeating ones--so I can't really use the Binding Tab option--if that makes a difference.

The loop script successfully launches the messageBox with the correct message, and assigns the "u" value to a text field in the correct subform, but the setfocus to the same field fails--I get a malformed SOM error message.

xfa.host.messageBox(conCat("Please answer question #",i+1), "You Missed a Question",3)
SubformQ1[i].TxtArrow = "u"
xfa.host.setFocus("form1.SubformTypeQs.SubformQ1[i].TxtArrow")

I've tried resolveNode various ways--but I might be using that incorrectly. Also tried setFocus to other objects in the subform (exclusionGroup & TextObject) and even the checkBox within the exclusionGroup. I'd like to stick with formCalc, if possible, since I've already written over 70 lines of complicated code on this button and this is the only bug.

Any suggestions?

Stephen

3 Replies

Avatar

Level 7

Update:

If I remove the "" from

xfa.host.setFocus("form1.SubformTypeQs.SubformQ1[i].TxtArrow")

to

xfa.host.setFocus(form1.SubformTypeQs.SubformQ1[i].TxtArrow)

The malformed SOM expression error message goes away--however, it still doesn't setFocus.

I even tried

xfa.host.setFocus(form1.SubformTypeQs.SubformQ1[2].TxtArrow)

and No Error Message and still no setFocus.

Stephen

Avatar

Level 10

Hi Stephen,

As you are using FormCalc you do not need to resolve the node, however you do need to give a full reference. Use the quotes in FormCalc, but add "xfa.form." in front of the string. Also check that the rest of the reference is correct and full.

I have an old example here, that uses JavaScript: https://acrobat.com/#d=RZ1lzX23*u7L4N9rtWCYPQ

Hope that helps,

Niall

Avatar

Level 7

Hi Niall,

I've had a little progress--thanks for the help! (part of the problem was "xfa.form.form1. vs. "xfa.form1.)

However--I still have a problem.

            xfa.host.messageBox(conCat("Please answer question #",i+1), "You Missed a Question",3) 
            SubformQ1[i].TxtArrow = "u"
            xfa.host.setFocus("xfa.form.form1.SubformTypeQs.SubformQ1[i].TxtArrow")

Now, the script below works IF I substitute an integer for the i :

     xfa.host.setFocus("xfa.form.form1.SubformTypeQs.SubformQ1[5].TxtArrow")  //works!

The script fails with the i in place EVEN THOUGH the script right before it works:

            SubformQ1[i].TxtArrow = "u" //works!
             xfa.host.setFocus("xfa.form.form1.SubformTypeQs.SubformQ1[i].TxtArrow")  //fails--no error message.

WOW! WOW! WOW!  As I was writing this, I thought I'd try stealing a play from the javaScript playbook:

     xfa.host.setFocus(conCat("xfa.form.form1.SubformTypeQs.SubformQ1[",i,"].TxtArrow"))

This works!!!!!

Thanks,

Stephen