Findrecord and findvalue methods are so slow for set a record for current.
Instead of these filter method can be use but with filter just filtered records can be view. If you want see all records and set cursor to a specific record can use this way which I found at a blog uses from Axapta with also original lookup forms:
element.args().lookupField(fieldnum(SMAServiceOrderTable, ServiceOrderId));
element.args().lookupValue(_order.ServiceOrderId);
SMAServiceOrderTable_ds.executeQuery();
It's so fast but don't forget to use indexed field for search.
4 Temmuz 2013 Perşembe
24 Haziran 2013 Pazartesi
AXAPTA - Make display methods faster with cacheAddMethod
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;
}
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;
}
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
6 Haziran 2013 Perşembe
AXAPTA - Begin and end of the day
info( strfmt("%1 --- %2", datetobeginUtcDateTime( today() , DateTimeUtil::getUserPreferredTimeZone() ) ,
datetoendUtcDateTime( today(), DateTimeUtil::getUserPreferredTimeZone() )));
datetoendUtcDateTime( today(), DateTimeUtil::getUserPreferredTimeZone() )));
23 Mayıs 2013 Perşembe
AXAPTA - Copy to clipboard
FileIoPermission _perm = new FileIoPermission("myfile.txt",'r');
TextBuffer txtBuff = new TextBuffer();
;
// from text file
_perm.assert();
txtb.fromFile("myfile.txt");
txtBuff.toClipboard();
// from string
txtBuff.setText("my test buffer...");
txtBuff.toClipboard();
TextBuffer txtBuff = new TextBuffer();
;
// from text file
_perm.assert();
txtb.fromFile("myfile.txt");
txtBuff.toClipboard();
// from string
txtBuff.setText("my test buffer...");
txtBuff.toClipboard();
19 Nisan 2013 Cuma
AXAPTA - Show company logo at reports
First you have to upload company logo. For this:
From Basic->Setup->Company informations->Company logo upload your logo.
After that write code below which I found from this address as display method:
Display Bitmap CompanyLogo()
{
CompanyInfo companyInfo = CompanyInfo::find();
;
return CompanyImage::find(companyInfo.DataAreaId, companyInfo.TableId, companyInfo.RecId).Image;
}
Pull this method to header. Don't forget arrange Height and Width values manual and change ResizeBitmap property to Yes.
From Basic->Setup->Company informations->Company logo upload your logo.
After that write code below which I found from this address as display method:
Display Bitmap CompanyLogo()
{
CompanyInfo companyInfo = CompanyInfo::find();
;
return CompanyImage::find(companyInfo.DataAreaId, companyInfo.TableId, companyInfo.RecId).Image;
}
Pull this method to header. Don't forget arrange Height and Width values manual and change ResizeBitmap property to Yes.
25 Mart 2013 Pazartesi
AXAPTA Read text file
...
Filename Filename;
System.IO.StreamReader readFile;
System.String line;
int hwnd;
;
hwnd = infolog.hwnd();
Filename = WinApi::getOpenFileName(hwnd,['TXT files','*.txt'],"","Text Files");
// Filename = WinApi::getOpenFileName(element.hWnd(),['TXT files','*.txt'],"","Text Files");
if (!Filename)
return;
readFile = new System.IO.StreamReader(filename,System.Text.Encoding::get_UTF8());
while (true)
{
line = readFile.ReadLine();
if(System.String::IsNullOrEmpty(line))
break;
warning(line);
}
readFile.Close();
readFile.Dispose();
...
There are other ways, one of them is at Fatih Demirci's blog.
Filename Filename;
System.IO.StreamReader readFile;
System.String line;
int hwnd;
;
hwnd = infolog.hwnd();
Filename = WinApi::getOpenFileName(hwnd,['TXT files','*.txt'],"","Text Files");
// Filename = WinApi::getOpenFileName(element.hWnd(),['TXT files','*.txt'],"","Text Files");
if (!Filename)
return;
readFile = new System.IO.StreamReader(filename,System.Text.Encoding::get_UTF8());
while (true)
{
line = readFile.ReadLine();
if(System.String::IsNullOrEmpty(line))
break;
warning(line);
}
readFile.Close();
readFile.Dispose();
...
There are other ways, one of them is at Fatih Demirci's blog.
Kaydol:
Kayıtlar (Atom)