Axapta may call display methods over and over when navigating in table. If there are a lot of display methods it would be a trouble. cacheAddMethod provides save display methods at server and gives good performance increase. This method can be call after datasource's init method. If called from at wrong place it would be a reason of frozen of Axapta. Also this type display methods should be "table" methods.
This technique also works for edit methods.
public void init()
{
super();
this.cacheAddMethod(tableMethodStr(B_CallTrack, CustomerName));
this.cacheAddMethod(tableMethodStr(B_CallTrack, EndUserWarrantyStart));
this.cacheAddMethod(tableMethodStr(B_CallTrack, ExtendedWarrantyDate));
this.cacheAddMethod(tableMethodStr(B_CallTrack, ModelGroupID));
}
Cached display/edit methods don't update before update methods run. When necessary refresh display methods before update, you may use cacheCalculateMethod:
B_CallTrack_DS.cacheCalculateMethod(tableMethodStr(B_CallTrack, EndUserWarrantyStart));
Update for AX 2012:
This process eaiser with AX 2012. You can use SysClientCacheDataMethodAttribute. There's an optiona parameter too. If you send true for this parameter update issue at upper solved with automatically. But with this way display/edit method will be cached in all forms. If you don't want this old way sill valid.
[SysClientCacheDataMethodAttribute(true)]
display name dispCustName()
{
return CustTable::find(this.CustAccount).Name;
}
method etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
method etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
24 Haziran 2013 Pazartesi
AXAPTA - Display method authorization check
//BP Deviation documented
display CustName customerName()
{
CustName custName = '';
DictTable dictTable = new DictTable(tablenum(CustTable));
;
if (dictTable.rights() >= AccessType::View)
{
custName = CustTable::find(this.CustAccount).Name;
}
return custName;
}
display CustName customerName()
{
CustName custName = '';
DictTable dictTable = new DictTable(tablenum(CustTable));
;
if (dictTable.rights() >= AccessType::View)
{
custName = CustTable::find(this.CustAccount).Name;
}
return custName;
}
Etiketler:
authorization check,
AX,
AXAPTA,
display,
method
2 Aralık 2011 Cuma
AXAPTA edit method sample
Edit method let us show a field of another table and tie it with a field of our table. In this sample ServiceObjectId fields value changes related with ItemId updates. We get ServiceObjectId fields value, put ItemId which has this ServiceObjectId value. When ItemId changed we update ServiceObjectId value.
edit ItemId EditItemId(boolean set, ItemId _ItemId)
{
ItemId ret;
;
if (set)
{
this.ServiceObjectId =
SMAServiceObjectTable::findItem(_ItemId).ServiceObjectId;
}
else
{
ret = SMAServiceObjectTable::find(this.ServiceObjectId).ItemId;
}
return ret;
}
Set boolean value selects if editmethod will work for update or just display. If set true it's mean second parameter (in this case _ItemId ) filled from user. Else editmethod value cames from related field value.
edit ItemId EditItemId(boolean set, ItemId _ItemId)
{
ItemId ret;
;
if (set)
{
this.ServiceObjectId =
SMAServiceObjectTable::findItem(_ItemId).ServiceObjectId;
}
else
{
ret = SMAServiceObjectTable::find(this.ServiceObjectId).ItemId;
}
return ret;
}
Set boolean value selects if editmethod will work for update or just display. If set true it's mean second parameter (in this case _ItemId ) filled from user. Else editmethod value cames from related field value.
30 Kasım 2011 Çarşamba
AXAPTA modified method sometimes works twice
If combobox value selected with lookup and there is a data source refresh in method modified, modified method works twice. Another person faced this situation and unfortunately had not found a solution.
public void modified()
{
;
super();
info("111");
salesLine_DS.research(true);
salesLine_DS.refresh();
info("222");
}
I found a solution for that and applined mine. I put a variable at class declaration method and:
public void modified()
{
;
super();
if (hasChanged) //for twice call bugfix.
return;
hasChanged=true;
info("111");
salesLine_DS.research(true);
salesLine_DS.refresh();
hasChanged=false;
info("222");
}
public void modified()
{
;
super();
info("111");
salesLine_DS.research(true);
salesLine_DS.refresh();
info("222");
}
I found a solution for that and applined mine. I put a variable at class declaration method and:
public void modified()
{
;
super();
if (hasChanged) //for twice call bugfix.
return;
hasChanged=true;
info("111");
salesLine_DS.research(true);
salesLine_DS.refresh();
hasChanged=false;
info("222");
}
Kaydol:
Kayıtlar (Atom)