Set focus on field in Kinetic form

I realize this is a total hack, but we weren’t able to find out a different way to set this. If anyone has a better way, I would love to change the way we’re doing this. But it is possible to set focus to a particular field in kinetic.

In our case, we were doing this in pack out entry. When we pack and unpack, we want the focus to return to the part number field after they enter the quantity. To do this, we created an event that triggers after ColumnChanged_Quantity. In the event we added a condition object, and then added an event complete.

image

For the condition expression we had the system evaluate a setTimeout method after a half a second (500 milliseconds). The function executed gets the reference to particular control (txtPartNum2 in our case), and then gets the reference to the input element and sets the focus to the input element. Here is our condition expression:

eval(“setTimeout(function(){this.document.getElementById(‘txtPartNum2’).getElementsByTagName(‘input’)[0].focus()},500)”)

The setTimeout was the key for us. We could get other events to fire, but they were all firing too quickly to set the focus.

1 Like

Did you attempt the control-focus-set? Was the timing the issue on why this approach didn’t work?

We use it in events to set the focus as the final step:

image

1 Like

Yes, we tried that first. We tried it up and down the event chain, even all the way to the very last event that is run. Still didn’t work for us.

3 Likes

Curious… did you use the “on success” type connector like in the above image? Just wondering if that may have been why there were timing issues, it wasn’t waiting for the previous event to be “successful” before changing focus.

Dunno… again, just curious.

1 Like

When we were trying this without a condition, the control focus set was the only object in the event besides the trigger. The event trigger was after the last event in the chain. There wasn’t an option to mark the connector as “on success” when it was coming from the trigger. The condition is only in there because it allows me to perform javascript which allows me to perform the delay.

What if you set this up as an onblur event of the Qty field? So, when focus leaves the Qty field, the event would fire and set focus to the partnum field.

What you have works, obviously… I’m not trying to be argumentative or anything. Hope I’m not coming off that way. Just spit balling ideas.

1 Like

No worries. We tried onblur and had the same issue. Because the built in process updates when the quantity field changes, it seems that all these events fire while everything is disabled. Thus the delay. The delay fixed everything. Maybe it would help to have a delay object in the event toolbox?

For now. Eval is going away at some point.

1 Like

For what it’s worth, this works in 2024.2

No joy in 2024.1, however. Scratch that, I can’t type. It works in 2024.1 as well.

Final edit–I did not read anything in between the original post and replying, so if there’s extra info invalidating my response… whoops. Lol #Friday

3 Likes

We’re planning a move to 2024.2 when it is released for on premises. This doesn’t work for us in 2024.1. This might be a screen specific issue.

2 Likes

Which is a good thing.

However, they need to let us insert real javascript from the backend.

1 Like