UnitOfMeasureConverter::convert(
this.PurchReceivedNow, UnitOfMeasure::unitOfMeasureIdBySymbol(this.PurchUnit),
UnitOfMeasure::unitOfMeasureIdBySymbol(this.inventTable().inventUnitId()),
NoYes::Yes,
InventTable::itemProduct(this.ItemId) or InventTable.product)
2016-11-16
[AX2012] Unit Conversion Sample Code
Sample:
2016-11-14
[AX2012] Error: Logon failed for the unattended execution account
Error while setting server report parameters. Error message: The report server has encountered a configuration error. Logon failed for the unattended execution account. (rsServerConfigurationError)
Solution:
Solution:
- Check your Service Account user & password in Reporting Service Configuration Manager.
- Check your Execution Account user & password in Reporting Service Configuration Manager.
2016-11-02
[AX2009] Merge Query Range from Two Different Queries
In my case, I want to merge query ranges from Query object to Form Data source. The data source will join to CustTable. The CustTable will be filtered by Query Object TIDCustTable.
When click Select button:
Merge method:
public class FormRun extends ObjectRun
{
QueryBuildDatasource qbds3;
Query q3;
QueryRun qRunCustTable;
}
public void init()
{
QueryBuildDatasource qbds1, qbds4;
;
qRunCustTable = new QueryRun(QueryStr(TIDCustTable));
super();
qbds1 = TIDIRTable_ds.query().dataSourceTable(tablenum(TIDIRTable));
qbds4 = SalesTableDS_ds.query().dataSourceTable(tablenum(SalesTable));
qbds4.addLink(fieldnum(TIDIRTable, SalesId), fieldnum(SalesTable, SalesId));
qbds3 = qbds1.addDataSource(tablenum(CustTable));
qbds3.addLink(fieldnum(TIDIRTable, InvoiceAccount), fieldnum(CustTable, AccountNum));
}
When click Select button:
void btnSelect()Process button:
{
;
if(qRunCustTable.prompt())
{
q3 = new Query(qRunCustTable.query());
}
}
public void btnProcess()
{
QueryBuildDatasource qbds1 = TIDIRTable_ds.query().dataSourceTable(tablenum(TIDIRTable));
QueryBuildDatasource qbds4 = SalesTableDS_ds.query().dataSourceTable(tablenum(SalesTable));
;
if(element.validateProcess())
{
qbds3.clearRanges();
if(qRunCustTable.query().dataSourceTable(tablenum(CustTable)).rangeCount() >0)
element.mergeRanges(TIDIRTable_ds.query(), qRunCustTable.query(), 4);//4 is table number of CustTable in TIDIRTable query
SysQuery::findOrCreateRange(qbds1, fieldnum(TIDIRTable, InvoiceDate)).value(SysQuery::range(dtFromDate.dateValue(), dtToDate.dateValue()));
if(txBranch.valueStr())
{
SysQuery::findOrCreateRange(qbds1, fieldnum(TIDIRTable, CountryRegionId)).value(SysQuery::value(txCountryRegionId.valueStr()));
SysQuery::findOrCreateRange(qbds1, fieldnum(TIDIRTable, Branch)).value(SysQuery::value(txBranch.valueStr()));
}
else
{
if(qbds1.findRange(fieldnum(TIDIRTable, CountryRegionId)))
qbds1.clearRange(fieldnum(TIDIRTable, CountryRegionId));
if(qbds1.findRange(fieldnum(TIDIRTable, Branch)))
qbds1.clearRange(fieldnum(TIDIRTable, Branch));
}
if(cbSalesStatus.selection() == SalesStatus::None)
{
qbds4.joinMode(JoinMode::OuterJoin);
if(qbds4.findRange(fieldnum(SalesTable, SalesStatus)))
{
qbds4.clearRange(fieldnum(SalesTable, SalesStatus));
}
}
else
{
qbds4.joinMode(JoinMode::InnerJoin);
SysQuery::findOrCreateRange(qbds4, fieldnum(SalesTable, SalesStatus)).value(SysQuery::value(cbSalesStatus.selection()));
}
TIDIRTable_ds.executeQuery();
}
}
Merge method:
public void mergeRanges(Query q,
Query initQ,
int dsNo,
int initQdsNo = 1,
boolean alwaysAddDatasource = false,
boolean addSameFieldRange = true)
{
QueryBuildRange fromQbr;
QueryBuildRange toQbr;
QueryBuildDynalink dyna;
Counter fromI = 1;
//int qdsNo = initQdsNo;
int qdsNo = dsNo;
Counter toI;
tableId tableId;
DictField dictField;
int dictIndex;
int originalId;
void add()
{
q.addDataSource(initQ.dataSourceNo(initQdsNo).file());
qdsNo = q.dataSourceCount();
}
void findToQbr(fieldId id)
{
originalId = id;
id = fieldExt2Id(id);
toQbr = null;
// get table id & dictField
tableId = q.dataSourceNo(qdsNo).table();
dictField = new DictField(tableId,id);
dictIndex = originalId >> 16;
// If this is a dimension field, get range using the array index, otherwise get range with id
if ( ((dictField.arraySize() > 1) && q.dataSourceNo(qdsNo).findRange(fieldId2Ext(id, dictIndex))) ||
((dictField.arraySize() <= 1) && q.dataSourceNo(qdsNo).findRange(id)) )
{
// If same range is found, then next range
if (! addSameFieldRange)
continue;
toI = 1;
while (toI)
{
// is this a Dimension field?
if (dictField.arraySize() > 1)
toQbr = q.dataSourceNo(qdsNo).findRange(fieldId2Ext(id, dictIndex),toI);
else
toQbr = q.dataSourceNo(qdsNo).findRange(id,toI);
if (! toQbr)
break;
// If To value is empty, use it later
if (! toQbr.value())
break;
// If To and From values are equal then add new range later
if (toQbr.value() == fromQbr.value())
break;
toI++;
}
}
if (! toQbr ||
(addSameFieldRange &&
toQbr &&
toQbr.value() &&
fromQbr.value() &&
toQbr.value() != fromQbr.value()
)
)
{
if (dictField.arraySize() > 1)
{
// yes, working with Dimension
toQbr = q.dataSourceNo(qdsNo).addRange(fieldId2Ext(id, dictIndex));
}
else
{
toQbr = q.dataSourceNo(qdsNo).addRange(id);
}
}
}
// Start
if (! initQ)
throw error(strfmt("@SYS23669",funcname()));
if (! initQ.dataSourceNo(initQdsNo))
throw error(strfmt("@SYS23667",funcname()));
if (! q)
throw error(strfmt("@SYS23669",funcname()));
/*
if (q.dataSourceCount() >= initQdsNo)
{
if (q.dataSourceNo(initQdsNo).file() != initQ.dataSourceNo(initQdsNo).file())
{
if (alwaysAddDatasource)
add();
else
throw error(strfmt("@SYS23668",funcname()));
}
}
else
add();
*/
if (! initQ)
return;
for (fromI=1;fromI<=initQ.dataSourceNo(initQdsNo).rangeCount();fromI++)
{
fromQbr = initQ.dataSourceNo(initQdsNo).range(fromI);
findToQbr(fromQbr.field());
if (toQbr)
{
// Only set if From has a value
if (fromQbr.value())
toQbr.value(fromQbr.value());
switch (fromQbr.status())
{
case RangeStatus::Locked:
if (toQbr.status() == RangeStatus::Open)
toQbr.status(RangeStatus::Locked);
break;
case RangeStatus::Hidden:
switch (toQbr.status())
{
case RangeStatus::Open,RangeStatus::Locked:
toQbr.status(RangeStatus::Hidden);
break;
}
break;
}
}
}
fromI = 1;
while (fromI <= initQ.dataSourceNo(initQdsNo).dynalinkCount())
{
dyna = initQ.dataSourceNo(initQdsNo).dynalink(fromI);
findToQbr(dyna.field());
if (toQbr)
toQbr.value(queryValue(dyna.cursor().(dyna.dynamicField())));
fromI++;
}
}
2016-07-19
[AX2012] No connection could be made because the target machine actively refused it 8201
Error: "No connection could be made because the target machine actively refused it 8201"
Solution: In database server, create client configuration to AOS Server make sure the Business Connector also point to AOS Server.
Solution: In database server, create client configuration to AOS Server make sure the Business Connector also point to AOS Server.
2016-04-26
[AX2012] No Fiscal Year Calendar Has Been Defined For Ledger
When posting Product Receipt the error show that Cannot create a record in Global address book and No fiscal year calendar has been defined for ledger. In this case, the user don't have access to class SubLedgerJournalizer method getFiscalCalendarPeriod. Give the access to the user privileges.
[AX2012] Error code: 38 = Filename too long
When print ssrs report VendInvoiceDocument the error showed up. It said that the filename is too long. After I checked the size of the file (my case: axapd.alt), the file was corrupted. In normal size the file size is 8KB but currently the size is 1KB. Stop the AOS and replaced the corrupted file with the normal file and then start the AOS. Well, it worked fine.
2016-04-12
[AX2012] Preview Pane on SalesTableListPage or PurchTableListpage Disapear
When you set a security on SalesTableListPage, PurchTableListPage, etc and you see no line preview pane, set the security access to line preview pane menu item. For example in SalesTableListPage form, set the security access to SalesTableListPagePreviewPane menu item.
2016-04-11
[AX2012] The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
Error message showed when SSRS report was opened : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Solution: Check windows and router firewall.
Solution: Check windows and router firewall.
2016-03-21
[AX2012] Ax error "A user session on the server could not be created. Try to start the client again. If the problem continues contact Ax Administrator"
I checked the Event viewer and found that the log file was full:
Object Server 01: The database reported (session 1 (-AOS-)): [Microsoft][SQL Server Native Client 10.0][SQL Server]The transaction log for database
'AXDatabase' is full due to 'LOG_BACKUP'. . The SQL statement was: "UPDATE SQLSYSTEMVARIABLES SET VALUE='34' WHERE PARM='SYSVARID'"
Solution:
Stop the AOS.
Shrink database log file and start the AOS.
Object Server 01: The database reported (session 1 (-AOS-)): [Microsoft][SQL Server Native Client 10.0][SQL Server]The transaction log for database
'AXDatabase' is full due to 'LOG_BACKUP'. . The SQL statement was: "UPDATE SQLSYSTEMVARIABLES SET VALUE='34' WHERE PARM='SYSVARID'"
Solution:
Stop the AOS.
Shrink database log file and start the AOS.
2016-03-20
[AX2012] Enable/Disable Buttons on PurchTable or SalesTable Form by Code
To enable or disable buttons on PurchTableListPage, PurchTable, SalesTableListPage or SalesTable form, you can edit on these classes:
These class can affect PurchTableListPage or SalesTableListPage forms.
- PurchTableListPageInteraction
- PurchTableInteraction
- PurchTableInteractionHelper
- SalesTableListPageInteraction
- SalesTableInteraction
- SalesTableInteractionHelper
These class can affect PurchTableListPage or SalesTableListPage forms.
2016-03-17
[AX2012] QR Code
Here is the sample to generate QR Code in AX 2012. This code can be used for report by save the binData.getData() into container field in report temporary table. You can download the xpo here.
public class FormRun extends ObjectRun
{
Microsoft.Dynamics.QRCode.Encoder qrCode;
System.Drawing.Bitmap netBitmap;
BinData binData;
Image image;
}
public void init()
{
super();
qrCode = new Microsoft.Dynamics.QRCode.Encoder();
qrCode.set_Version(40);
qrCode.set_ErrorCorrectionLevel(Microsoft.Dynamics.QRCode.ErrorCorrectionLevel::High); binData = new BinData();
image = new Image();
}
void createQR()
{
Filename filename;
FileIOPermission perm = null;
;
netBitmap = qrCode.Encode(Text.text());
filename = qrCode.GetTempFile(Text.text());
perm = new FileIOPermission(filename, 'RW');
perm.assert();
binData.loadFile(filename);
image.setData(binData.getData());//binData.getData() return a container
QRImage.image(image);
if(WinAPI::fileExists(filename))
{
WinAPI::deleteFile(filename);
}
CodeAccessPermission::revertAssert();
//info(filename);
}
public void textChange()
{
super();
element.createQR();
}
public class FormRun extends ObjectRun
{
Microsoft.Dynamics.QRCode.Encoder qrCode;
System.Drawing.Bitmap netBitmap;
BinData binData;
Image image;
}
public void init()
{
super();
qrCode = new Microsoft.Dynamics.QRCode.Encoder();
qrCode.set_Version(40);
qrCode.set_ErrorCorrectionLevel(Microsoft.Dynamics.QRCode.ErrorCorrectionLevel::High); binData = new BinData();
image = new Image();
}
void createQR()
{
Filename filename;
FileIOPermission perm = null;
;
netBitmap = qrCode.Encode(Text.text());
filename = qrCode.GetTempFile(Text.text());
perm = new FileIOPermission(filename, 'RW');
perm.assert();
binData.loadFile(filename);
image.setData(binData.getData());//binData.getData() return a container
QRImage.image(image);
if(WinAPI::fileExists(filename))
{
WinAPI::deleteFile(filename);
}
CodeAccessPermission::revertAssert();
//info(filename);
}
public void textChange()
{
super();
element.createQR();
}
2016-03-16
[AX2012] SSRS Report Error at The Fisrt Time After Restarting AOS
"The DefaultValue expression for the report parameter ‘AX_CompanyName’ contains an error: Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed. (rsRuntimeErrorInExpression)"
Solution:
- Go to System administration>Setup>System>System service accounts.
- Retype the business connector proxy account ("domain\username").
Subscribe to:
Posts (Atom)