// IN form Gird select some records and click button. in button properties MultiSelect: YES
void clicked()
{
CustTable _CustTable;
;
super();
if(CustTable_ds.anyMarked())
{
_CustTable = CustTable_Ds.getFirst(1,false);
while(_CustTable)
{
info(_CustTable.AccountNum);
_CustTable = CustTable_Ds.getNext();
}
}
}
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.
27 May 2011
DictTable and DictField
static void SystemClassesFields(Args _args)
{
SysDictTable dictTable;
DictField dictField;
Common common;
Counter counter;
;
dictTable = new SysDictTable(tableNum(CustTable));
for (counter=1; counter<=dictTable.fieldCnt(); counter++)
{
dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(counter));
if (dictField.isSystem())
{
info(strfmt("System field: %1", dictField.label()));
info(strfmt("System field: %1", dictField.name()));
}
else
info(strfmt("User field: %1", dictField.label()));
}
}
{
SysDictTable dictTable;
DictField dictField;
Common common;
Counter counter;
;
dictTable = new SysDictTable(tableNum(CustTable));
for (counter=1; counter<=dictTable.fieldCnt(); counter++)
{
dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(counter));
if (dictField.isSystem())
{
info(strfmt("System field: %1", dictField.label()));
info(strfmt("System field: %1", dictField.name()));
}
else
info(strfmt("User field: %1", dictField.label()));
}
}
Common
static void Common(Args _args)
{
Common common;
CustTable custTable;
;
common = custTable;
if (common.tableId == tablenum(custTable))
{
while select common
{
info(common.(fieldnum(custTable, name)));
}
}
}
{
Common common;
CustTable custTable;
;
common = custTable;
if (common.tableId == tablenum(custTable))
{
while select common
{
info(common.(fieldnum(custTable, name)));
}
}
}
working with table buffers
static void OneCursor(Args _args)
{
CustTable custTable, newCustTable;
;
select firstonly custTable;
newCustTable = custTable;
}
--
static void TwoCursors(Args _args)
{
CustTable custTable, newCustTable;
;
select firstonly custTable;
newCustTable.data(custTable);
}
--
static void DataDic_MultipleCursors(Args _args)
{
CustTable custTable, newCustTable;
;
while select custTable
{
newCustTable.data(custTable);
//info(newCustTable.AccountNum);
}
}
{
CustTable custTable, newCustTable;
;
select firstonly custTable;
newCustTable = custTable;
}
--
static void TwoCursors(Args _args)
{
CustTable custTable, newCustTable;
;
select firstonly custTable;
newCustTable.data(custTable);
}
--
static void DataDic_MultipleCursors(Args _args)
{
CustTable custTable, newCustTable;
;
while select custTable
{
newCustTable.data(custTable);
//info(newCustTable.AccountNum);
}
}
20 May 2011
Time Field Comparison
// This is a job to understand about time values comparison and time field values comparison //using dialog
static void TimeComparison(Args _args)
{
TimeofDay fromTime,toTime; // Time variables
//TimeDate tbTime; // Table Buffer
Dialog dlg = new Dialog("TimeComparision");// object created for Dialog
dialogField dlgField,dlgField2;// Dialog Fields
TimeofDay fTime,tTime; // Time variables
;
dlgField = dlg.addFieldValue(typeid(TimeofDay),"","FromTime");
dlgField2 = dlg.addFieldValue(typeid(TimeofDay),"ToTime","ToTime");
if(dlg.run())
{
fromTime = dlgField.value();
toTime = dlgField2.value();
}
// fromTime = str2time("03:00:00 am");// we can change the time into string format
// toTime = str2time("04:00:00 am");
if(fromTime < toTime) { info("This is the small time"); info(time2str(fromTime,1,1)); } else if(fromTime > toTime)
{
info("From Time should be less than To time ");
info(time2str(toTime,1,1));
}
else
info("Enter the time");
//-----------------------------
// To compare we can use this function: str2time("11:00:00 am")
//while select tbTime where tbTime.FromTime == str2time("11:00:00 am")
//{
//print tbTime.FromTime;
//info(time2str(tbTime.FromTime,1,1));
//}
//print time;
//pause;
tTime = str2time("03:00:00 am");
tTime = str2time("04:00:00 am");
if(tTime == str2time("3:00:00:am"))
{
print tTime;
}
pause;
}
static void TimeComparison(Args _args)
{
TimeofDay fromTime,toTime; // Time variables
//TimeDate tbTime; // Table Buffer
Dialog dlg = new Dialog("TimeComparision");// object created for Dialog
dialogField dlgField,dlgField2;// Dialog Fields
TimeofDay fTime,tTime; // Time variables
;
dlgField = dlg.addFieldValue(typeid(TimeofDay),"","FromTime");
dlgField2 = dlg.addFieldValue(typeid(TimeofDay),"ToTime","ToTime");
if(dlg.run())
{
fromTime = dlgField.value();
toTime = dlgField2.value();
}
// fromTime = str2time("03:00:00 am");// we can change the time into string format
// toTime = str2time("04:00:00 am");
if(fromTime < toTime) { info("This is the small time"); info(time2str(fromTime,1,1)); } else if(fromTime > toTime)
{
info("From Time should be less than To time ");
info(time2str(toTime,1,1));
}
else
info("Enter the time");
//-----------------------------
// To compare we can use this function: str2time("11:00:00 am")
//while select tbTime where tbTime.FromTime == str2time("11:00:00 am")
//{
//print tbTime.FromTime;
//info(time2str(tbTime.FromTime,1,1));
//}
//print time;
//pause;
tTime = str2time("03:00:00 am");
tTime = str2time("04:00:00 am");
if(tTime == str2time("3:00:00:am"))
{
print tTime;
}
pause;
}
16 May 2011
Crosscompany to get data from other companies / Get the data from other companies
CrossCompany is the Keyword to get the data from other companies..
static void CrossCompany_test(Args _args)
{
CustTable custTable;
container conCompanies = [ 'USMF', 'USRT', 'USSI' ]; // you can assign the selected company
str comp;
;
while select crossCompany : conCompanies * from custTable
{
info( custTable.AccountNum + " : " + custTable.name() + " : " + custTable.dataAreaId);
}
}
static void CrossCompany_test(Args _args)
{
CustTable custTable;
container conCompanies = [ 'USMF', 'USRT', 'USSI' ]; // you can assign the selected company
str comp;
;
while select crossCompany : conCompanies * from custTable
{
info( custTable.AccountNum + " : " + custTable.name() + " : " + custTable.dataAreaId);
}
}
Create virtual company accounts
Virtual company accounts contain data that is shared across company accounts. This type of account enables users to post information in one company that is available to another company.
Prerequisites
Requirements to create or modify a virtual company accountare as follows:
Must be running a single instance of the Application Object Server (AOS). All other AOS computers must be shut down.
Must be logged in as an administrator.
Only one active client connection is allowed.
Create a virtual company account
Click Administration > Setup > Virtual company accounts.
Enter the company identification in the Company accounts field.
Enter the name of the virtual company in the Name of company accounts field.
Click the Company accounts tab.
Select the company accounts to participate in the virtual company.
To add a virtual company account, select the company name under Remaining company accounts and then click the left arrow (<) to move it to the Selected company accounts list. To remove a virtual company account, select the company name under Selected company accounts and then click right arrow (>) to move it to the Remaining company accounts.
Click the Table collections tab and select the table collections that contain the specific tables that you want to share in the virtual company.
To add a table collection, select the table collection name under Remaining table collections and then click the left arrow (<) to move it to the Selected table collections list. To remove a table collection, select the table collection name under Selected table collections and then click the left arrow (>) to move it to the Remaining table collections list.
Table collections are groups of tables. They can be created by developers through drag-and-drop functionality in the Application Object Tree (AOT).
Shut down and restart the Microsoft Dynamics AX client.
You must restart the Microsoft Dynamics AX client to update the client with the new virtual company account information.
Prerequisites
Requirements to create or modify a virtual company accountare as follows:
Must be running a single instance of the Application Object Server (AOS). All other AOS computers must be shut down.
Must be logged in as an administrator.
Only one active client connection is allowed.
Create a virtual company account
Click Administration > Setup > Virtual company accounts.
Enter the company identification in the Company accounts field.
Enter the name of the virtual company in the Name of company accounts field.
Click the Company accounts tab.
Select the company accounts to participate in the virtual company.
To add a virtual company account, select the company name under Remaining company accounts and then click the left arrow (<) to move it to the Selected company accounts list. To remove a virtual company account, select the company name under Selected company accounts and then click right arrow (>) to move it to the Remaining company accounts.
Click the Table collections tab and select the table collections that contain the specific tables that you want to share in the virtual company.
To add a table collection, select the table collection name under Remaining table collections and then click the left arrow (<) to move it to the Selected table collections list. To remove a table collection, select the table collection name under Selected table collections and then click the left arrow (>) to move it to the Remaining table collections list.
Table collections are groups of tables. They can be created by developers through drag-and-drop functionality in the Application Object Tree (AOT).
Shut down and restart the Microsoft Dynamics AX client.
You must restart the Microsoft Dynamics AX client to update the client with the new virtual company account information.
09 May 2011
Query Filter in form
In new form->write a method in DS->
void filterOnVendTable()
{
QueryBuildRange vendorAccountFilter;
;
vendorAccountFilter = this.query().dataSourceNo(1).addRange(fieldnum(VendTable, AccountNum));
vendorAccountFilter.value("3000..3010");
}
____
Call this method in DS->Init()
public void init()
{
super();
this.filterOnVendTable();
}
void filterOnVendTable()
{
QueryBuildRange vendorAccountFilter;
;
vendorAccountFilter = this.query().dataSourceNo(1).addRange(fieldnum(VendTable, AccountNum));
vendorAccountFilter.value("3000..3010");
}
____
Call this method in DS->Init()
public void init()
{
super();
this.filterOnVendTable();
}
05 May 2011
Close AXAPTA with X++ , shut down AX with X++ code
public static void shutdownAxapta()
{
SysGlobalCache cache = appl.globalCache();
info info;
;
cache.set(classstr(info), identifierstr(Autologoff), true);
info=new info();
info.shutDown(true);
}
{
SysGlobalCache cache = appl.globalCache();
info info;
;
cache.set(classstr(info), identifierstr(Autologoff), true);
info=new info();
info.shutDown(true);
}
02 May 2011
Dialog Field Validation
In Report this if for to check the null values.
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();
if(_CustAccount == "")
{
checkfailed("Enter the value");
}
else
ret = true;
return ret;
}
______
This is to validate based on the condition.
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();
if(_CustAccount >= "4000" && _CustAccount <="4010")
{
ret = true;
}
else
checkfailed("Enter the values bet ween 4000 to 4010");
return ret;
}
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();
if(_CustAccount == "")
{
checkfailed("Enter the value");
}
else
ret = true;
return ret;
}
______
This is to validate based on the condition.
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();
if(_CustAccount >= "4000" && _CustAccount <="4010")
{
ret = true;
}
else
checkfailed("Enter the values bet ween 4000 to 4010");
return ret;
}
Subscribe to:
Posts (Atom)
Ledger Voucher creation Framework and x++ code to create ledger voucher
Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...