Ex:1 Report with datasource added
//Take a Report and Add a Table.
//Make sure that Table Properties set as "Temporary: YES" or
//In Report init method write this code "Tmtab.setTmp();" to make tamp
//Write the following code in the report Fetch Method
public boolean fetch()
{
str acc;
boolean ret;
// ret = super();
while select custTable
{
Tmtab_1.CustAccount = custTable.AccountNum;
Tmtab_1.doInsert();
this.send(Tmtab_1);
}
return true;
}
Ex:2 Report without Datasource
Step:1
Write the below code in fetch method
public boolean fetch()
{
str acc;
boolean ret;
// ret = super();
while select custTable
{
Tmtab.CustAccount = custTable.AccountNum;
Tmtab.doInsert();
//this.send(Tmtab);
element.execute(1);
}
return true;
}
Step:2
Create a display method and return the field value
//BP Deviation Documented
display CustAccount acc()
{
return Tmtab.CustAccount;
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
29 September 2010
Working with Temporary Tables in forms
Ex: 1 Temp Table in Job
-----
static void tempTableData(Args _args)
{
CustTable custTable,tmpCustTable;
;
// Here setting custtable as Temprorary Table
tmpCustTable.setTmp();
while select custTable
{
//Here we are puting data to tempTable
tmpCustTable.data(custTable.data());
//printing tmpCustTable data
info(tmpCustTable.AccountNum);
}
}
----
Ex 2: Forms with datasource added
//Take a Form and Add a Table.
//Make sure that Table Properties set as "Temporary: YES" or
//In Form init method write this code "Tmtab.setTmp();" to make tamp
//Write the following code in the Form DataSource init() Method
public void init()
{
super();
while select custTable
{
TempTab.CustAccount = custTable.AccountNum;
TempTab.doInsert();
}
}
Ex 3: Forms without datasource added
.
.
.
Soon
-----
static void tempTableData(Args _args)
{
CustTable custTable,tmpCustTable;
;
// Here setting custtable as Temprorary Table
tmpCustTable.setTmp();
while select custTable
{
//Here we are puting data to tempTable
tmpCustTable.data(custTable.data());
//printing tmpCustTable data
info(tmpCustTable.AccountNum);
}
}
----
Ex 2: Forms with datasource added
//Take a Form and Add a Table.
//Make sure that Table Properties set as "Temporary: YES" or
//In Form init method write this code "Tmtab.setTmp();" to make tamp
//Write the following code in the Form DataSource init() Method
public void init()
{
super();
while select custTable
{
TempTab.CustAccount = custTable.AccountNum;
TempTab.doInsert();
}
}
Ex 3: Forms without datasource added
.
.
.
Soon
28 September 2010
Using DictTable
static void dictTable_Ex(Args _args)
{
DictTable dictTable;
DictField dictField;
TableId tableId;
FieldId fieldId;
;
tableId = tablenum(CustTable);
dictTable = new DictTable(tableId);
if(dictTable)
{
fieldId = dictTable.primaryKeyField();
if(0 != fieldId)
{
dictField = new DictField(tableId, fieldId);
if(dictField)
{
print strfmt("Primary key field name: %1", dictField.name());
pause;
}
}
}
}
{
DictTable dictTable;
DictField dictField;
TableId tableId;
FieldId fieldId;
;
tableId = tablenum(CustTable);
dictTable = new DictTable(tableId);
if(dictTable)
{
fieldId = dictTable.primaryKeyField();
if(0 != fieldId)
{
dictField = new DictField(tableId, fieldId);
if(dictField)
{
print strfmt("Primary key field name: %1", dictField.name());
pause;
}
}
}
}
Write EXCEL Document, export data to excel with X++
static void CreateExcelDocument (Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
// Name of the Excel document.
fileName = "C:\\test.xslx";
// Excel open and initialize.
xlsApplication = SysExcelApplication:: construct ();
xlsApplication.visible (true);
// Create an Excel Worksheet produce.
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum (1);
// Write to the worksheet cells headings.
xlsWorkSheet.cells (). item (row, 1). value ('Account Number');
xlsWorkSheet.cells (). item (row,2). value ('name');
row ++;
// Excel Worksheet with data fill / (Excel cells fill).
while select custTable
{
xlsWorkSheet.cells (). item (row, 1). value (custTable.AccountNum);
xlsWorkSheet.cells (). item (row, 2). value (custTable.Name);
row ++;
}
// Check whether the document already exists.
if (WINAPI:: fileExists (fileName))
{
Winapi:: DeleteFile (fileName);
}
// Save Excel document.
xlsWorkbook.saveAs(fileName);
// Close Excel.
xlsApplication.quit ();
xlsApplication.finalize ();
}
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
// Name of the Excel document.
fileName = "C:\\test.xslx";
// Excel open and initialize.
xlsApplication = SysExcelApplication:: construct ();
xlsApplication.visible (true);
// Create an Excel Worksheet produce.
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum (1);
// Write to the worksheet cells headings.
xlsWorkSheet.cells (). item (row, 1). value ('Account Number');
xlsWorkSheet.cells (). item (row,2). value ('name');
row ++;
// Excel Worksheet with data fill / (Excel cells fill).
while select custTable
{
xlsWorkSheet.cells (). item (row, 1). value (custTable.AccountNum);
xlsWorkSheet.cells (). item (row, 2). value (custTable.Name);
row ++;
}
// Check whether the document already exists.
if (WINAPI:: fileExists (fileName))
{
Winapi:: DeleteFile (fileName);
}
// Save Excel document.
xlsWorkbook.saveAs(fileName);
// Close Excel.
xlsApplication.quit ();
xlsApplication.finalize ();
}
22 September 2010
Convert date type to datetime type in ax
static void convertDateToDateTime(Args _arg)
{
date d = today();
int timeOfDay;
UTCDateTime datetime;
;
timeOfDay = str2time('00:00:00');
datetime = DateTimeUtil::newDateTime(d, timeOfDay);
pause;
}
{
date d = today();
int timeOfDay;
UTCDateTime datetime;
;
timeOfDay = str2time('00:00:00');
datetime = DateTimeUtil::newDateTime(d, timeOfDay);
pause;
}
15 September 2010
Code To Copy Table records between Companies, crosscompnay
static void Transfer_Rec(Args _args)
{
DictTable dicttable;
DictField dictfield;
Common common,common1;
int fieldcnt,i;//Returns the number of fields for the table
fieldId fieldid; //Field from usertable
UserTable TempTable,TempTable1; // UserTable is the table, whose data u want to copy
;
while select TempTable
{
common = TempTable;
dicttable = new DictTable(common.TableId);
changeCompany("tst")
{
TempTable1 = null;
common1 = TempTable1;
fieldcnt = dicttable.fieldCnt();
for (i = 1; i <= fieldcnt; i++)
{
fieldid = dicttable.fieldCnt2Id(i);
dictfield = new dictfield(common.TableId,fieldid);
if (dictfield.id() == fieldname2id(common.TableId,identifierstr(dataareaid)))
continue;
else
common1.(dictfield.id()) = common.(dictfield.id());
}
common1.insert();
}
}
print strfmt('done');
pause;
}
{
DictTable dicttable;
DictField dictfield;
Common common,common1;
int fieldcnt,i;//Returns the number of fields for the table
fieldId fieldid; //Field from usertable
UserTable TempTable,TempTable1; // UserTable is the table, whose data u want to copy
;
while select TempTable
{
common = TempTable;
dicttable = new DictTable(common.TableId);
changeCompany("tst")
{
TempTable1 = null;
common1 = TempTable1;
fieldcnt = dicttable.fieldCnt();
for (i = 1; i <= fieldcnt; i++)
{
fieldid = dicttable.fieldCnt2Id(i);
dictfield = new dictfield(common.TableId,fieldid);
if (dictfield.id() == fieldname2id(common.TableId,identifierstr(dataareaid)))
continue;
else
common1.(dictfield.id()) = common.(dictfield.id());
}
common1.insert();
}
}
print strfmt('done');
pause;
}
14 September 2010
Microsoft Dynamics AX Frameworks
1. Runbase Framework
2. Batch Framework
3. Dialog Framework
4. Operation Progress Framework
5. NumberSequence Framework
6. SysLastValue Framework
7. AIF-Application Integration Framework
8. Wizard Framework
9. Infolog Framework
10.Unit Test Framework
2. Batch Framework
3. Dialog Framework
4. Operation Progress Framework
5. NumberSequence Framework
6. SysLastValue Framework
7. AIF-Application Integration Framework
8. Wizard Framework
9. Infolog Framework
10.Unit Test Framework
Subscribe to:
Posts (Atom)
Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O
[DataContractAttribute] class ABCUserProfilesBulkDeleteContract { UserId userId; [DataMemberAttribute('UserId')] pu...
-
Please click here to access Custom Workflow step by step process:
-
public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation) { InventOnhand inventOnh...
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...