1

I'm looking for the possibility to set the focus to the Inventory ID field when the add new record button is clicked using javascript.

I've already managed to set the focus to the Inventory ID field but this only happens when the form is initialized, I've done that by using the following javascript code snippet

<script type="text/javascript">
    function FormView_Load() {
        px_callback.addHandler(setFocusOnCustRef);
        return;
    }

    var setFocus = true;

    function setFocusOnCustRef(context, error) {             
        if (setFocus === true) {
            setFocus = false;
            var InventoryID = px_alls["edInventoryCD"];
            InventoryID.focus();
        }
        return;
    }
</script>

The result I'm expecting is to set the focus when the page starts (Working so far) and when the Add New button is clicked on the page as well (this behavior doesn't Initialize the form again so it won't set the focus to the field).

1 Answers1

1

Set value for the Initialize on the form properties.

enter image description here

Vardan Vardanyan
  • 649
  • 5
  • 12
  • I found out that adding a CallbackCommand to the repaint all controls to the Insert Command and then setting the Client Event AfterRepaint (on the image) with a new JavaScript function that sets the focus works like a charm. @Vardan-Vardanyan – DanielMoncadaZ Sep 13 '19 at 15:06