I found this solution from a blog which I cannot remember. Turkish letters (or another special letters with some languages) will not shown when send mail with sysMailer class if you won't add this red line:
SysEmailParameters parameters;
SysMailer mailer;
;
new InteropPermission(InteropKind::ComInterop).assert();
parameters = SysEmailParameters::find();
mailer = new SysMailer();
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(fromAddr);
mailer.tos().appendAddress(toAddr);
mailer.subject(subject);
//solution for turkish letter problem (ÖöÇçĞğÜüŞşİı):
mailer.bodyCharSet("Windows-1254"); if(FileName)
mailer.attachments().add(FileName);
mailer.ccs().appendAddress(ccAddr);
mailer.bccs().appendAddress(bccAddr);
mailer.htmlBody(body);
mailer.sendMail();
}
CodeAccessPermission::revertAssert();
24 Mart 2016 Perşembe
AXAPTA - Solve of turkish letter problem when send mail with sysmailer class
2 Mart 2016 Çarşamba
AXAPTA - Find a table fields label value
There are two ways to find a table field's label value:
If fields label value derived from directly fields extended data type:
if (curext()=="krc" && this.RBOInventItemGroupId == "")
ret = checkfailed(strfmt("'%1' field cannot be empty!..",
new SysDictType(extendedTypeNum(RBORetailGroupId)).label()));
If there is a special label value dedicated at table level:
if (curext()=="krc" && this.RBOInventItemGroupId == "")
ret = checkfailed(strfmt("'%1' field cannot be empty!..",
new SysDictField(tablenum(WholeSalesCampaignGroup),
fieldnum(WholeSalesCampaignGroup,RBOInventItemGroupId)).label()));
If fields label value derived from directly fields extended data type:
if (curext()=="krc" && this.RBOInventItemGroupId == "")
ret = checkfailed(strfmt("'%1' field cannot be empty!..",
new SysDictType(extendedTypeNum(RBORetailGroupId)).label()));
If there is a special label value dedicated at table level:
if (curext()=="krc" && this.RBOInventItemGroupId == "")
ret = checkfailed(strfmt("'%1' field cannot be empty!..",
new SysDictField(tablenum(WholeSalesCampaignGroup),
fieldnum(WholeSalesCampaignGroup,RBOInventItemGroupId)).label()));
5 Şubat 2016 Cuma
AXAPTA - Prevent user to change filter from grid header
SysQuery::findOrCreateRange(InventDim_DS.query().dataSourceTable(tablenum(InventDim)),fieldnum(InventDim,InventSiteId)).status(RangeStatus::Locked);
26 Ocak 2016 Salı
AX 2009 - Run report at back ground as PDF output
Make Interactive property of report as No. It's easy make it as run for html with change PrintMedium enum's value.
DocuType docuType;
TextIo textIo;
FileIOPermission fioPermission;
#File
ReportRun report;
;
docuType = DocuType::find("Temp");
fileName = strfmt(@"%1My Test Report.PDF", docuType.ArchivePath);
fioPermission = new FileIOPermission(fileName ,"RW");
fioPermission.assert();
if(Global::isRunningOnServer())
{
if(WinAPIServer::fileExists(fileName))
WINAPIServer::deleteFile(fileName);
}
else
{
if(WinAPI::fileExists(fileName))
WINAPI::deleteFile(fileName);
}
report = new ReportRun(new Args(ReportStr(KRC_InventCoverReport)));
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().preferredTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName(fileName);
report.query().interactive(false);
report.run();
DocuType docuType;
TextIo textIo;
FileIOPermission fioPermission;
#File
ReportRun report;
;
docuType = DocuType::find("Temp");
fileName = strfmt(@"%1My Test Report.PDF", docuType.ArchivePath);
fioPermission = new FileIOPermission(fileName ,"RW");
fioPermission.assert();
if(Global::isRunningOnServer())
{
if(WinAPIServer::fileExists(fileName))
WINAPIServer::deleteFile(fileName);
}
else
{
if(WinAPI::fileExists(fileName))
WINAPI::deleteFile(fileName);
}
report = new ReportRun(new Args(ReportStr(KRC_InventCoverReport)));
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().preferredTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName(fileName);
report.query().interactive(false);
report.run();
22 Ocak 2016 Cuma
Axapta - Why sometimes MultiSelectionHelper and why sometimes traditional read?
That's the traditional way to read selected records from a grid:
c = CustTable_DS.getFirst(true);
while (c.RecId != 0)
{
info(c.Name);
c = CustTable_DS.getNext();
}
But there's a problem with this way. If user just wants to process records at line instead of select a couple of records unfortunately that record will be missed. That's the workaround for this symptom:
c = CustTable_DS.getFirst(true);
noSelected = true;
while (c.RecId != 0)
{
noSelected = false;
info(c.Name);
c = CustTable_DS.getNext();
}
if (noSelected)
info(CustTable.Name);
MultiSelectionHelper solves this problem:
MultiSelectionHelper helper = MultiSelectionHelper::construct();
CustTable c;
;
helper.parmDatasource(CustTable_ds);
c = helper.getFirst();
while (c.RecId != 0)
{
info(c.Name);
c = helper.getNext();
}
But there is a disadvantage for MultiSelectionHelper class too. If user wants to sort records at grid and wants to process with this sorted list we have to use traditional way again because unfortunately MultiSelectionHelper doesn't care about users sort.
Using MultiselectionHelper from a class:
public static void main(Args _args)
{
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
info(strFmt("%1",serviceOrder.RecId));
serviceOrder = helper.getNext();
}
}
c = CustTable_DS.getFirst(true);
while (c.RecId != 0)
{
info(c.Name);
c = CustTable_DS.getNext();
}
But there's a problem with this way. If user just wants to process records at line instead of select a couple of records unfortunately that record will be missed. That's the workaround for this symptom:
c = CustTable_DS.getFirst(true);
noSelected = true;
while (c.RecId != 0)
{
noSelected = false;
info(c.Name);
c = CustTable_DS.getNext();
}
if (noSelected)
info(CustTable.Name);
MultiSelectionHelper solves this problem:
MultiSelectionHelper helper = MultiSelectionHelper::construct();
CustTable c;
;
helper.parmDatasource(CustTable_ds);
c = helper.getFirst();
while (c.RecId != 0)
{
info(c.Name);
c = helper.getNext();
}
But there is a disadvantage for MultiSelectionHelper class too. If user wants to sort records at grid and wants to process with this sorted list we have to use traditional way again because unfortunately MultiSelectionHelper doesn't care about users sort.
Using MultiselectionHelper from a class:
public static void main(Args _args)
{
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
info(strFmt("%1",serviceOrder.RecId));
serviceOrder = helper.getNext();
}
}
Etiketler:
AX,
ax 2012,
AXAPTA,
getfirst,
getnext,
grid,
multi,
multiselect,
multiselectionhelper,
record,
select,
sort
19 Ocak 2016 Salı
Axapta - Add dimension based filter to a query
When we try to add filter based on StrFmt like this; dimension[2] = "0001" it gives error because of brackets. I found the solution from a forum page :
QueryBuildDataSource qbds = query.addDataSource(tablenum(EmplTable));
...
qbds.addRange(fieldid2Ext(fieldnum(EmplTable, Dimension),1)).value("600742");
QueryBuildDataSource qbds = query.addDataSource(tablenum(EmplTable));
...
qbds.addRange(fieldid2Ext(fieldnum(EmplTable, Dimension),1)).value("600742");
23 Aralık 2015 Çarşamba
Axapta - Add date and time to XPO export dialog form
With this feature XPO files will be version controlled. I got this useful for backup code from Eren Polat .
Add these code parts to SysExportDialog forms methods:
classDeclaration:
str sDate, sTime, sDateTime;
str sMilliSeconds;
init:
sMilliSeconds = int2str(winApi::getTickCount());
sDate = int2str(year(today())) + strReplace(num2str(mthofyr(today()),2,0,0,0), ' ', '0') + strReplace(num2str(dayofmth(today()),2,0,0,0), ' ', '0');
sTime = strfmt("%1:%2", time2str(timeNow(),1,1), substr(sMilliSeconds, strlen(sMilliSeconds)-2,2));
sTime = strReplace(sTime,":","");
sDateTime = strfmt("_%1%2",sDate,sTime);
run:
//element.updateBox(fileNameNext(strfmt('%1%2_%3%4', filePath, preFix, treeNode.treeNodeName(), #xpo)));
element.updateBox(fileNameNext(strfmt('%1%2_%3%4%5', filePath, preFix, treeNode.treeNodeName(), sDateTime, #xpo)));
Add these code parts to SysExportDialog forms methods:
classDeclaration:
str sDate, sTime, sDateTime;
str sMilliSeconds;
init:
sMilliSeconds = int2str(winApi::getTickCount());
sDate = int2str(year(today())) + strReplace(num2str(mthofyr(today()),2,0,0,0), ' ', '0') + strReplace(num2str(dayofmth(today()),2,0,0,0), ' ', '0');
sTime = strfmt("%1:%2", time2str(timeNow(),1,1), substr(sMilliSeconds, strlen(sMilliSeconds)-2,2));
sTime = strReplace(sTime,":","");
sDateTime = strfmt("_%1%2",sDate,sTime);
run:
//element.updateBox(fileNameNext(strfmt('%1%2_%3%4', filePath, preFix, treeNode.treeNodeName(), #xpo)));
element.updateBox(fileNameNext(strfmt('%1%2_%3%4%5', filePath, preFix, treeNode.treeNodeName(), sDateTime, #xpo)));
Kaydol:
Kayıtlar (Atom)