Expand my Community achievements bar.

SOLVED

Set Focus target when Add New Instance

Avatar

Level 2

[LC Designer ES2 9.0] Using Action Builder to add a new instance of subform SITE, where first field is called SiteName.

If I set action to Set Focus to SiteName, the focus goes to the *original* SiteName field instead of to the new instance.

Users will typically add a number of additional sites and, each time, I want the focus to be set on the first field of the newest instance, not the original instance. How do I accomplish that? Thanks!           ~Carol

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

There is no attachment ....can you send it to LiveCycle8@gmail.com

Paul

View solution in original post

5 Replies

Avatar

Former Community Member

This is not as easy as it sounds. The ability to move the cursor to a new field is an AcroForm level command. When you add an instance of a subform the objects do not exist on the AcroForm side until the script is finished. In your case you want to mmove the cursor in the same script that will add the subform so the standard cursor reposition command will not work (as the new field dose not exist yet). There is an acroform command that will allow you to execute a command in the future (presumably when the script is finished and the objects actually exist). Unfortunately you must use the acrofom name to address the field. Here is a snippet of code that shows you the command that you need to use. Note that you will have to replace the object names with your own (the one that is between the single quotes):

var setField = app.setTimeOut("this.getField('form1[0].Page3[0].TextField4[0]').setFocus();", 1);

Paul

Avatar

Level 2

I understand the concept (I think...), but am not clear on where to place the code.

I used Action Builder to create an AddSite action: when check box chkAddSite is checked | Add a new instance of subformSiteInfo | and set visibility of subformSiteInfo to visible. Does your code go in that same action sequence? If so, what is the next Action Builder result selection? If not, where do I insert it?

I never know whether the new instance of the subform will begin on the following page, so the user might keep clicking the chkAddSite box, thinking it didn't work. Although, thinking this through, maybe I could force the new subform instance to always appear at the top of the following page, and somehow direct the focus there, rather than to the specific first field???

Thanks!         ~Carol

Avatar

Former Community Member

I assume that you are activating the subform instance by clicking a button. The code would go on the click event of that button. There will be code there from the action builder so simply add it to the bottom of that script.

Your other idea wodul be fine. You coudl put a small 1pxel by 1 pixel field at the top of the page and simply set the focus to that field (it will already exist). Just make sure that you turn off the borders and captions and make the background and foreground color of the field the same as the background color of the form so that the field is not discernable by the user.

Hope that helps

Paul

Avatar

Level 2

Unfortunately, I am still having trouble with this.

My goal (see attached): When btnAddProgramInfo is clicked, add new instance of subProgramInfo at the top of next (new) page and set cursor focus to txtServiceProgName in the new instance.

The section before Program Information will be multiple/unknown number of pages

Each completed Program Information section could span several pages, and users could need to add as many as 20 programs. There is nothing following the Program Info section.

Sorry to be so dense, but I just can't seem to set the cursor focus in each new instance, no matter what I try.

Thanks in advance! ~Carol

Avatar

Correct answer by
Former Community Member

There is no attachment ....can you send it to LiveCycle8@gmail.com

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----