gotFocus and enter methods on Form field not being called
Asked Answered
C

1

6

I have some fields in my Sales Order Form (SalesTable) that need to be disabled if another field is set to a specific value. To do this I overrode the enter and the gotFocus methods on the form field (I did both to test it out). The code compiles and doesn't have any issues.

My issue is that neither of these overridden methods are called when I click on a field in the appropriate grid column. What would cause the enter and the gotFocus methods to not be called on a grid field?

Candytuft answered 15/2, 2012 at 14:25 Comment(4)
Did you put your code before or after the super() call?Inattention
I tried both before and after. Which is the correct one to do? I assumed before. Also, my methods are deleted by the AX whenever I leave that area and go somewhere else to edit code.Candytuft
This is because AutoDataGroup is Yes. The group is recreated on every run.Ashraf
That makes so much more sense and your solution was what I ended up finding but your answer and comment shed a lot of light why everything was doing what it did.Candytuft
A
8

Do not use the gotFocus and enter methods.

Make a datasource method to make the the change:

void setAllowEdit()
{ 
    salesTable_ds.object(fieldnum(SalesTable, Name)).allowEdit(salesTable.SalesType == SalesType::Journal);
}

Call the method from the the active method:

public int active()
{
    int ret = super();
    ...
    this.setAllowEdit()
    return ret;
}

Call the method from the datasource field (in this case the SalesType field):

public void modified()
{
    super()
    salesTable_ds.setAllowEdit()
    element.changeType(); // standard code
}
Ashraf answered 15/2, 2012 at 15:34 Comment(3)
just browsing some questions and wondering, what does changeType do here?Yakut
Take a look on form method SalesTable.changeType().Ashraf
Aha - so it is specific to the SalesTable form, that is fine - I implemented this on another form and was hoping/checking I hadn't missed a best practice.Yakut

© 2022 - 2024 — McMap. All rights reserved.