Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

More setFocus formCalc

Avatar

Former Community Member
I found $host.setFocus( STRING param ) but cannot get it to work.



I want my script in Object1 to take the user to Object2.



I have tried variations of $host.setFocus( STRING Object2 ) to no avail. That would include $host.setfocus( STRING F.P1.Object2 . . .).



Can anyone shed light? Please. This should be simple.



Thanks.
6 Replies

Avatar

Former Community Member
Chris,



The code should be:



$host.setFocus("Object2")



This works as long as the objects are in the same hierarchy.



Catherine

Avatar

Former Community Member
I have never been able to get this to work. I would like the first field on the form the have the cursor in it when the form is ready. How do I do this?

Avatar

Former Community Member
Paul,



You can place:

$host.setFocus("TextField1") in the docReady event (or any other object that you want to be the first focus).



Catherine

Avatar

Former Community Member
Thanks. I got it working. Did realize you had to put the code in the object you want focus to be set to.



Thanks.