Trivia:
It is usual programming pattern in AX that one overrides active() method on the datasource to allow/disallow data entry on fields depending on values of any fields in record.
It is also usual pattern to do similar thing overriding modified() method on datasource fields.
I would like to warn anyone using that pattern , that every screen in AX2009 SP0 will fail to behave as expected.
Problem:
When you re-read the contents of the record on the form using F5 function key, AX 2009 SP0 does call the datasource's active method, allowing you to re-set access ( _DS.object().allowEdit(...) )
but DOES NOT call *_DS.active() method when one press Ctrl-F5.
Scenario of failure:
User arrives at the record, enters some data , is allowed access to the other fields (based on previous input).
Now user presses Ctrl-F5, and all field values return to initially fetched, but *_DS.active() method is not called, potentially making editable fields which were not available upon arrival to that record. User happily changes the data, and developer ask himself a question how did it happened.
BTW: _DS.cursorNotify() is not called either.
It would be good if someone would confirm this behaviour in AX4 and AX2009SP1
Solution:
For the time being there's small generic solution to this. You need to modify the SysSetupFormRun.task() to make it call active() after Ctrl-F5 was pressed.
public int task(int _p1)
{
#task
FormDataSource formDataSource;
{
#task
FormDataSource formDataSource;
int ret;
if (_p1 == #taskFilter)
{
formDataSource = this.objectSet();
if (formDataSource &&
formDataSource.queryRun() &&
formDataSource.queryRun().args() &&
!formDataSource.queryRun().args().caller())
{
formDataSource.queryRun().args().caller(this);
}
}
{
formDataSource = this.objectSet();
if (formDataSource &&
formDataSource.queryRun() &&
formDataSource.queryRun().args() &&
!formDataSource.queryRun().args().caller())
{
formDataSource.queryRun().args().caller(this);
}
}
ret = super(_p1);
//mku------------------------------------------------- to call the datasource's active and allow re-setting the access----------
if(_p1 == 2839)
{
formDataSource = this.objectSet();
if(formDataSource)
{
formDataSource.active();
}
}
//mku------------------------------------------------- to call the datasource's active and allow re-setting the access----------
if(_p1 == 2839)
{
formDataSource = this.objectSet();
if(formDataSource)
{
formDataSource.active();
}
}
//mku ------------------------------------------------------ end ------------------------------------------------------------
return ret;
}
return ret;
}
No comments:
Post a Comment