if (x == 1) { y = 2; }
is better than
if (x == 1) y = 2;
?
Find a bug in Dynamics AX 2012 RTM then:
if (x == 1) { y = 2; }
if (x == 1) y = 2;
public static server str purchLineTableId() { return SysComputedColumn::returnLiteral(tableNum(PurchLine)); }
public static server str purchLineTableId() { return SysComputedColumn::returnLiteral(tableNum(PurchLineHistory)); }
if (!myTable.isTempDb()) { myTable.setTmp(); }
static void AnotherWayToExportToExcel(Args _args)
{
#define.ReadWritePermission('RW')
#define.FileName('c:\myFile.xlsx')
#define.ExcelColumnWidth(15)
#define.ExcelCellFontSize("Microsoft.Dynamics.AX.Fim.Spreadsheets.CellFontSize")
#define.Size9("Size9")
CustTable custTable;
Microsoft.Dynamics.AX.Fim.Spreadsheets.Spreadsheet spreadsheet;
Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties cellProperties;
Microsoft.Dynamics.AX.Fim.Spreadsheets.ColumnProperties columnProperties;
void addColumn(str _name)
{
columnProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.ColumnProperties();
columnProperties.set_Width(#ExcelColumnWidth);
spreadSheet.InstantiateColumn(columnProperties);
cellProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties();
cellProperties.set_FontSize(CLRInterop::parseClrEnum(#ExcelCellFontSize, #Size9));
cellProperties.set_Bold(true);
spreadSheet.AddStringCellToWorkbook(_name, cellProperties);
}
new FileIOPermission(#FileName, #ReadWritePermission).assert();
spreadSheet = new Microsoft.Dynamics.AX.Fim.Spreadsheets.Spreadsheet();
if (!spreadSheet.CreateSpreadsheet(#FileName))
{
throw error(strFmt("@SYS72245", #FileName));
}
addColumn("Customer name");
addColumn("Balance");
while select custTable
{
spreadSheet.MoveToNextRowInWorkbook();
cellProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties();
cellProperties.set_FontSize(CLRInterop::parseClrEnum(#ExcelCellFontSize, #Size9));
spreadSheet.AddStringCellToWorkbook(custTable.name(), cellProperties);
spreadSheet.AddNumberCellToWorkbook(real2double(custTable.openBalanceCur()), cellProperties);
}
spreadSheet.WriteFile();
spreadSheet.Dispose();
CodeAccessPermission::revertAssert();
}
static void main(Args _args) { #define.TmpInventTransMarkDsNo(2) #define.InventTransOriginDsNo(4) #define.InventTransOriginMarkDsNo(5) #define.MarkNowControlName('markNow') #define.PurchLineLotId("GSC-000983") #define.SalesLineLotId("GSC-000982") FormRun formRun; Args args; TmpInventTransMark tmpInventTransMark; SalesLine salesLine; InventTransOrigin salesLineOrigin; PurchLine purchLine; InventTransOrigin inventTransOriginMark; FormCheckBoxControl markNowCheckBox; purchLine = PurchLine::findInventTransId(#PurchLineLotId); args = new Args(); args.name(formStr(InventMarking)); args.record(purchLine); // Work-around: first if-statement in // Classes\ReqCalc\argsItemId method expects a caller args.caller(new InventMarkingEmulator()); formRun = classfactory.formRunClass(args); formRun.init(); formRun.run(); // The temp table is filled in when this active() is called formRun.dataSource(#InventTransOriginDsNo).active(); tmpInventTransMark = formRun.dataSource(#TmpInventTransMarkDsNo).cursor(); inventTransOriginMark = formRun.dataSource(#InventTransOriginMarkDsNo).cursor(); ttsbegin; // Find the required reference and mark it formRun.dataSource(#TmpInventTransMarkDsNo).first(); Debug::assert(tmpInventTransMark.RecId != 0); do { if (inventTransOriginMark.InventTransId == #SalesLineLotId) { markNowCheckBox = formRun.design().controlName(#MarkNowControlName); markNowCheckBox.value(1); markNowCheckBox.clicked(); formRun.closeOk(); break; } } while (formRun.dataSource(#TmpInventTransMarkDsNo).next()); ttscommit; }
void clicked()
{
container breakpoints;
boolean enable = true;
xRefReferences xRefReferencesLocal;
breakpoints = infolog.breakpoint();
for (xRefReferencesLocal = XRefReferences_ds.getFirst(true) ?
XRefReferences_ds.getFirst(true) : XRefReferences_ds.cursor();
xRefReferencesLocal;
xRefReferencesLocal = XRefReferences_ds.getNext())
{
if (xRefReferencesLocal.line > 0)
{
breakpoints += [xRefReferencesLocal.path()];
breakpoints += [xRefReferencesLocal.line];
breakpoints += [enable];
}
}
infolog.breakpoint(breakpoints);
}
static void fixTableAndFieldIds(Args _args)
{
Dictionary dictionary = new Dictionary();
SysDictTable dictTable;
DictField dictField;
TableId tableId;
FieldId fieldId;
SqlDictionary sqlDictionaryTable;
SqlDictionary sqlDictionaryField;
setPrefix("Update of data dictionary IDs");
tableId = dictionary.tableNext(0);
ttsbegin;
while (tableId)
{
dictTable = new SysDictTable(tableId);
setPrefix(dictTable.name());
if (!dictTable.isSystemTable() && !dictTable.isView())
{
//Finds table in SqlDictionary by name in AOT, if ID was changed.
//Empty field ID represents a table.
select sqlDictionaryTable
where sqlDictionaryTable.name == dictTable.name()
&& sqlDictionaryTable.fieldId == 0
&& sqlDictionaryTable.tabId != dictTable.id();
if (sqlDictionaryTable)
{
info(dictTable.name());
//Updates table ID in SqlDictionary
if (ReleaseUpdateDB::changeTableId(
sqlDictionaryTable.tabId,
dictTable.id(),
dictTable.name()))
{
info(strFmt("Table ID changed (%1 -> %2)", sqlDictionaryTable.tabId, dictTable.id()));
}
}
fieldId = dictTable.fieldNext(0);
//For all fields in table
while (fieldId)
{
dictField = dictTable.fieldObject(fieldId);
if (!dictField.isSystem())
{
//Finds fields in SqlDictionary by name and compares IDs
select sqlDictionaryField
where sqlDictionaryField.tabId == dictTable.id()
&& sqlDictionaryField.name == dictField.name()
&& sqlDictionaryField.fieldId != 0
&& sqlDictionaryField.fieldId != dictField.id();
if (sqlDictionaryField)
{
//Updates field ID in SqlDictionary
if (ReleaseUpdateDB::changeFieldId(
dictTable.id(),
sqlDictionaryField.fieldId,
-dictField.id(),
dictTable.name(),
dictField.name()))
{
info(strFmt("Pre-update: Field %1 - ID changed (%2 -> %3)",
dictField.name(),
sqlDictionaryField.fieldId,
-dictField.id()));
}
}
}
fieldId = dictTable.fieldNext(fieldId);
}
fieldId = dictTable.fieldNext(0);
//For all fields in table
while (fieldId)
{
dictField = dictTable.fieldObject(fieldId);
if (!dictField.isSystem())
{
select sqlDictionaryField
where sqlDictionaryField.tabId == dictTable.id()
&& sqlDictionaryField.name == dictField.name()
&& sqlDictionaryField.fieldId < 0;
if (sqlDictionaryField)
{
//Updates field ID in SqlDictionary
if (ReleaseUpdateDB::changeFieldId(
dictTable.id(),
sqlDictionaryField.fieldId,
-sqlDictionaryField.fieldId,
dictTable.name(),
dictField.name()))
{
info(strFmt("Final update: Field %1 - ID changed (%2 -> %3)",
dictField.name(),
sqlDictionaryField.fieldId,
-sqlDictionaryField.fieldId));
}
}
}
fieldId = dictTable.fieldNext(fieldId);
}
}
tableId = dictionary.tableNext(tableId);
}
ttscommit;
}
public boolean validateWrite() { boolean ok = true; ok = this.validateSomething() && ok; ok = this.validateSomethingElse() && ok; ... // johndoe 11.11.11 -> ok = this.validateWrittenByJohnDoe(); // johndoe 11.11.11 <- return ok; }