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 ();
}
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.
28 September 2010
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
Microsoft Dynamics AX Design Patterns
The Microsoft Dynamics AX design patterns listed below enable you to use existing code patterns
to resolve common design issues Click here
1. Instantiating Application Objects
2. Searching for Records
3. Searching for Multiple Occurrences
4. Parameter
5. static find Method
6. static exist Method
7. Pack-Unpack
8. Persistent Data Storage
9. Containers as Parameter Bags
10. Multi-selection
11. Partner Hooks
12. Use the Type System
13. Data Validation
14. Change Company
15. Storno
----
15.Change Company
static void main()
{
CustTable custTable;
;
// Assume that you are running in company 'aaa'.
changeCompany('bbb') // Default company is now 'bbb'.
{
custTable = null;
while select custTable
{
// custTable is now selected in company 'bbb'.
}
}
// Default company is again set back to 'aaa'.
changeCompany('ccc') // Default company is now 'ccc'.
{
// Clear custTable to let the select work
// on the new default company.
custTable = null;
while select custTable
{
// custTable is now selected in company 'ccc'.
}
}
// Default company is again 'aaa'.
}
to resolve common design issues Click here
1. Instantiating Application Objects
2. Searching for Records
3. Searching for Multiple Occurrences
4. Parameter
5. static find Method
6. static exist Method
7. Pack-Unpack
8. Persistent Data Storage
9. Containers as Parameter Bags
10. Multi-selection
11. Partner Hooks
12. Use the Type System
13. Data Validation
14. Change Company
15. Storno
----
15.Change Company
static void main()
{
CustTable custTable;
;
// Assume that you are running in company 'aaa'.
changeCompany('bbb') // Default company is now 'bbb'.
{
custTable = null;
while select custTable
{
// custTable is now selected in company 'bbb'.
}
}
// Default company is again set back to 'aaa'.
changeCompany('ccc') // Default company is now 'ccc'.
{
// Clear custTable to let the select work
// on the new default company.
custTable = null;
while select custTable
{
// custTable is now selected in company 'ccc'.
}
}
// Default company is again 'aaa'.
}
13 September 2010
insert_recordset & update_recordset
insert_recordset
void copySQLDictionary2DictionaryLine()
{
SqlDictionary sqlDictionary;
;
ttsBegin;
insert_recordset bufferDictionary(tabId, fieldId, array,
name, sqlName, fieldType, strSize, shadow,
rightJustify, nullable, flags)
select tabId, fieldId, array, name, sqlName, fieldType,
strSize, shadow, rightJustify, nullable, flags
from sqlDictionary
where sqlDictionary.tabId > 0;
ttsCommit;
}
------
update_recordset
MyTable myTableBuffer;
;
update_recordset myTableBuffer
setting
field1 = 1,
field2 = fieldX + fieldY
where field1 == 0;
void copySQLDictionary2DictionaryLine()
{
SqlDictionary sqlDictionary;
;
ttsBegin;
insert_recordset bufferDictionary(tabId, fieldId, array,
name, sqlName, fieldType, strSize, shadow,
rightJustify, nullable, flags)
select tabId, fieldId, array, name, sqlName, fieldType,
strSize, shadow, rightJustify, nullable, flags
from sqlDictionary
where sqlDictionary.tabId > 0;
ttsCommit;
}
------
update_recordset
MyTable myTableBuffer;
;
update_recordset myTableBuffer
setting
field1 = 1,
field2 = fieldX + fieldY
where field1 == 0;
13 August 2010
In SalesOrder (active Record) check the record is first packing slip has done or not,
form->DS->Methods->Active()
select firstonly custPackingSlipTrans
where custPackingSlipTrans.salesId == salesTable.salesId;
if(CustPackingSlipTrans)
{
element.toChangeTheNumSeq();//Method will exicute
}
select firstonly custPackingSlipTrans
where custPackingSlipTrans.salesId == salesTable.salesId;
if(CustPackingSlipTrans)
{
element.toChangeTheNumSeq();//Method will exicute
}
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...