Expand my Community achievements bar.

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

newText not functioning predictably

Avatar

Level 7

Greetings All,

I am using formCalc.

My form has a dropdown box that Allows Custom Text Entry. On the change event is a script like the following:

     SubformRecap.TableLiabilityRecap.Row[13].Cell[1] = xfa.event.newText

The custom entered text works ONLY when the user:

  • starts typing without viewing the dropdown choices or completely clears the field of the text of an unwanted choice
  • then, types the custom text
  • AND, then presses ENTER

    The script fails to capture the newText if ANY of the following occur

    • does not completely clear the dropdown box field contents
    • or, highlights and types over the highlighted text
    • or, uses TAB instead of ENTER when finished typing

    When it fails the following text/integer shows up in the referenced field: 1

    I have limited users so I suppose I could train them, however, I'd like to avoid that if at all possible. It is a large form and TAB the norm for entering and exiting fields. People are using this on their laptops in the field--so having quirks like this a major annoyance.

    Is change the right event? Is there some way to script the ENTER key (a virtual ENTER)?

    Thanks in advance!

    Stephen

    1 Accepted Solution

    Avatar

    Correct answer by
    Level 10

    Well, this problem sounds interesting... I've tried to rebuild it but to no avail, for me it works in any case so far.

    View solution in original post

    6 Replies

    Avatar

    Level 10

    Hmm,

    I could not reproduce this behavior.

    In my form the textfield always shows the changed value of the drop down immediately, no matter if I select an item before or highlight parts the values.

    Do you use scriptings to populate the drop down?

    Avatar

    Level 7

    Thanks Radzmar,

    Yes, when I build a simple form to test this, it works perfectly.

    The problem is bigger than I originally described!  Its not just the Custom Text entry. It is also the dropdown box item selection, as well.

    The target field populates as I type a Custom Text AND/OR the target field populates with the selected dropdown box item text, if the user selects a dropdown box item. So far, so good.

    However, if I TAB out of the dropdown box after I type a Custom Entry

    OR

    if I TAB out of the dropdown box after I select one of the dropdown items, the target field clears the text and shows the text/integer:  1

    If I hit ENTER after I type a Custom Entry

    OR

    If I hit ENTER after I select one of the dropdown items,  the target field keeps the text that has populated it. In other words, works as expected.

    There are NO scripts on the target field.

    There are 2 other scripts on the dropdown box:

    • preOpen to populate the dropdown box
    • Exit to hide/reveal a sibling text field

    I don't get it.  TAB and ENTER have different actions with a newText script on my form.

    Thanks,

    Stephen

    Avatar

    Level 7

    OK, I think I've figured out how to fix this.

    SubformRecap.TableLiabilityRecap.Row[13].Cell[1] = xfa.event.newText                   //this has a problem with TAB

    SubformRecap.TableLiabilityRecap.RowNamed.CellNamed = xfa.event.newText     // seems to work with TAB (still testing other places I use the newText script for targets in this table)

    I don't understand why? The first script finds the target either way and functions using ENTER (TAB puts "1" in the target)

    I use loops to do some things with some of the other table cells, so that is why they are all named Cell[*].  I can change that for this script and keep the names of the cells in the rows that are the target of my looping scripts the same--just change the integers in the looping scripts. Its a big form and will take some time to make all the changes.

    I would still like to understand why?

    Best,

    Stephen

    Avatar

    Level 7

    Hi All,

    I found that if my SOM contains any objects with multiple instances, I get the newText error described above (TAB has error, ENTER works fine):

    I have tried formCalc and javaScript, both with and without resolveNode()

    The script ALWAYS finds the target field, however with different results--so you would think that it is not a SOM issue.

    Change the target to one where the SOM has no objects with multiple instances, and TAB works!  So the SOM does make a difference, Why?

    I use the newText many times successfully in the form on SOMs without [ ]

    Several places, I don't have a choice--the SOMs will have [ ] so TAB will fail.and the user must use ENTER. This is not good!

    Any help is appreciated.

    Stephen

    Avatar

    Correct answer by
    Level 10

    Well, this problem sounds interesting... I've tried to rebuild it but to no avail, for me it works in any case so far.

    Avatar

    Level 7

    UPDATE:

    If anyone is working on the answer, please STOP. I am looking at all the scrpts, and so far I have found something that MAY BE causing the problem. I will start a new thread if I can't figure it out.

    Thanks,

    Stephen