Adapters that are included with Microsoft Dynamics AX are automatically registered during installation. Whenever a new adapter is added to the Application Object Tree (AOT), you must register the adapter to make it available in the integration ports. To register adapters, follow these steps.
1. Click System administration > Setup > Checklists > Initialization checklist.
2. Expand the Initialize system node.
3. Click Set up Application Integration Framework.
Adapters, basic ports, and services are registered. This operation can take some time to be completed.
Monday, August 6, 2012
Tuesday, February 28, 2012
Reading comma separated files in AX 2012
Example of the CommaIO class
FileName fileName = 'c:\\test.csv';
FileIoPermission permission;
CommaIO commaIO;
container readCon;
int i;
int level;
str column1;
str column2;
str column3;
;
permission= new FileIoPermission(filename,'r');
permission.assert();
commaIO = new CommaIo(filename, 'r');
commaIO.inFieldDelimiter(';'); // Delimiter...
if (commaIO)
{
while (commaIO.status() == IO_Status::OK)
{
readCon = commaIO.read();
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
info(strFmt("%1 - %2 - %3", column1, column2, column3));
}
}
FileName fileName = 'c:\\test.csv';
FileIoPermission permission;
CommaIO commaIO;
container readCon;
int i;
int level;
str column1;
str column2;
str column3;
;
permission= new FileIoPermission(filename,'r');
permission.assert();
commaIO = new CommaIo(filename, 'r');
commaIO.inFieldDelimiter(';'); // Delimiter...
if (commaIO)
{
while (commaIO.status() == IO_Status::OK)
{
readCon = commaIO.read();
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
info(strFmt("%1 - %2 - %3", column1, column2, column3));
}
}
Monday, February 21, 2011
.NET AX business connector
Integrate an Application with Microsoft Dynamics AX Using .NET Business Connector
The Microsoft Dynamics AX development environment enables you to integrate a .NET-connected application with Microsoft Dynamics AX. This feature gives a simplified way to develop integrations with Microsoft Dynamics AX using standard Microsoft developer tools such as Visual Studio .NET and the .NET Framework.
List of classes provided by business connector
• Axapta - The Axapta class provides the ability to connect to the Axapta system, create Axapta classes, create Axapta record, container, and buffer objects, execute transactions, and perform other Axapta system tasks.
• AxaptaBuffer - The AxaptaBuffer class provides the ability add data to and retrieve data from an Axapta buffer.
• AxaptaContainer - The AxaptaContainer class provides the ability to read and write to and from Axapta containers.
• AxaptaObject - The AxaptaObject class provides the ability to call Axapta class methods.
• AxaptaRecord - The AxaptaRecord class provides functionality for reading and modifying Axapta records.
Prerequisites
________________________________________
You will need to have:
• Microsoft Dynamics AX
• Visual Studio 2005 or Visual Studio 2008
• 2.0 .NET Framework
This walkthrough illustrates the following tasks:
• Create a C# Windows project
• Add a reference to .NET Business Connector
• Create the layout of a form
• Add code behind the form
Creating a C# Windows Project
________________________________________
The first step is to create a Windows application that will access data in Microsoft Dynamics AX.
To create a C# Windows project
1. Open Visual Studio.
2. From the File menu, click New, and then click Project to display the New Project dialog box.
3. In the Project types pane, click Visual C#. In the Templates pane, click Windows Application.
4. Set the name to DisplayAddressState.
5. To change the location of the solution directory, click Browse, and specify a new location.
6. Click OK.
Adding a Reference to .NET Business Connector
________________________________________
To access Microsoft Dynamics AX data, you must create a connection using .NET Business Connector. In this section, you will add a reference to the .NET Business Connector assembly.
To add a reference to .NET Business Connector
1. In Solution Explorer, right-click References, and then click Add Reference.
2. In the Add Reference window, click the Browse tab.
3. Specify the location of Microsoft.Dynamics.BusinessConnectorNet.dll, and then click Add.
4. Click OK.
Creating the Layout of a Form
________________________________________
After you have created DisplayAddressState, you can add controls to the form by dragging them from the toolbox.
To create the layout a form
1. In the toolbox, click the Label control, and then add it to the form.
2. Click the TextBox control and add it to the form next to the Label.
3. Click Button and add it to the form next to the TextBox.
4. Click Button and add it to the form next to the previous button.
Adding Code Behind the Form
________________________________________
In this section, you will add code behind the form to extract the data from Microsoft Dynamics AX. You will use the AxaptaRecord class to execute a query. This query will extract data from Microsoft Dynamics AX. You will retrieve and display customer data on the controls that you have added to the Windows form.
To add code on code behind of the form
On the form, double-click button1 to access the DisplayAxCustomer.Form1 code.
To fetch data from Axapta table:
using Microsoft.Dynamics.BusinessConnectorNet;
private void button1_Click(object sender, EventArgs e)
{
Axapta DynAx = new Axapta();
AxaptaRecord DynRec;
// Authenticate the user and establish a session.
DynAx.Logon(null, null, null, null);
// Define the record as the AddressState table.
DynRec = DynAx.CreateAxaptaRecord("AddressState");
// Define the query that will run on the AddressState records.
// This will return all the data in the AddressState table with
// the cursor positioned at the first record in the table.
DynRec.ExecuteStmt("select * from %1");
// Check if the query returned any data.
if(DynRec.Found)
{
// Display the record on the form that was retrieved from the query.
textBox1.Text = (string) DynRec.get_Field("Name");
}
}
Inserting records to Axapta table:
private void button2_Click(object sender, EventArgs e)
{
// Create the .NET Business Connector objects.
Axapta ax;
AxaptaRecord axRecord;
string tableName = "AddressState";
try
{
// Login to Microsoft Dynamics AX.
ax = new Axapta();
ax.Logon(null, null, null, null);
// Create a new AddressState table record.
using (axRecord = ax.CreateAxaptaRecord(tableName));
{
// Provide values for each of the AddressState record fields.
axRecord.set_Field("NAME", "MyState");
axRecord.set_Field("STATEID", "MyState");
axRecord.set_Field("COUNTRYREGIONID", "US");
axRecord.set_Field("INTRASTATCODE", "");
// Commit the record to the database.
axRecord.Insert();
}
}
catch (Exception e)
{
Console.WriteLine("Error encountered: {0}", e.Message);
// Take other error action as needed.
}
The Microsoft Dynamics AX development environment enables you to integrate a .NET-connected application with Microsoft Dynamics AX. This feature gives a simplified way to develop integrations with Microsoft Dynamics AX using standard Microsoft developer tools such as Visual Studio .NET and the .NET Framework.
List of classes provided by business connector
• Axapta - The Axapta class provides the ability to connect to the Axapta system, create Axapta classes, create Axapta record, container, and buffer objects, execute transactions, and perform other Axapta system tasks.
• AxaptaBuffer - The AxaptaBuffer class provides the ability add data to and retrieve data from an Axapta buffer.
• AxaptaContainer - The AxaptaContainer class provides the ability to read and write to and from Axapta containers.
• AxaptaObject - The AxaptaObject class provides the ability to call Axapta class methods.
• AxaptaRecord - The AxaptaRecord class provides functionality for reading and modifying Axapta records.
Prerequisites
________________________________________
You will need to have:
• Microsoft Dynamics AX
• Visual Studio 2005 or Visual Studio 2008
• 2.0 .NET Framework
This walkthrough illustrates the following tasks:
• Create a C# Windows project
• Add a reference to .NET Business Connector
• Create the layout of a form
• Add code behind the form
Creating a C# Windows Project
________________________________________
The first step is to create a Windows application that will access data in Microsoft Dynamics AX.
To create a C# Windows project
1. Open Visual Studio.
2. From the File menu, click New, and then click Project to display the New Project dialog box.
3. In the Project types pane, click Visual C#. In the Templates pane, click Windows Application.
4. Set the name to DisplayAddressState.
5. To change the location of the solution directory, click Browse, and specify a new location.
6. Click OK.
Adding a Reference to .NET Business Connector
________________________________________
To access Microsoft Dynamics AX data, you must create a connection using .NET Business Connector. In this section, you will add a reference to the .NET Business Connector assembly.
To add a reference to .NET Business Connector
1. In Solution Explorer, right-click References, and then click Add Reference.
2. In the Add Reference window, click the Browse tab.
3. Specify the location of Microsoft.Dynamics.BusinessConnectorNet.dll, and then click Add.
4. Click OK.
Creating the Layout of a Form
________________________________________
After you have created DisplayAddressState, you can add controls to the form by dragging them from the toolbox.
To create the layout a form
1. In the toolbox, click the Label control, and then add it to the form.
2. Click the TextBox control and add it to the form next to the Label.
3. Click Button and add it to the form next to the TextBox.
4. Click Button and add it to the form next to the previous button.
Adding Code Behind the Form
________________________________________
In this section, you will add code behind the form to extract the data from Microsoft Dynamics AX. You will use the AxaptaRecord class to execute a query. This query will extract data from Microsoft Dynamics AX. You will retrieve and display customer data on the controls that you have added to the Windows form.
To add code on code behind of the form
On the form, double-click button1 to access the DisplayAxCustomer.Form1 code.
To fetch data from Axapta table:
using Microsoft.Dynamics.BusinessConnectorNet;
private void button1_Click(object sender, EventArgs e)
{
Axapta DynAx = new Axapta();
AxaptaRecord DynRec;
// Authenticate the user and establish a session.
DynAx.Logon(null, null, null, null);
// Define the record as the AddressState table.
DynRec = DynAx.CreateAxaptaRecord("AddressState");
// Define the query that will run on the AddressState records.
// This will return all the data in the AddressState table with
// the cursor positioned at the first record in the table.
DynRec.ExecuteStmt("select * from %1");
// Check if the query returned any data.
if(DynRec.Found)
{
// Display the record on the form that was retrieved from the query.
textBox1.Text = (string) DynRec.get_Field("Name");
}
}
Inserting records to Axapta table:
private void button2_Click(object sender, EventArgs e)
{
// Create the .NET Business Connector objects.
Axapta ax;
AxaptaRecord axRecord;
string tableName = "AddressState";
try
{
// Login to Microsoft Dynamics AX.
ax = new Axapta();
ax.Logon(null, null, null, null);
// Create a new AddressState table record.
using (axRecord = ax.CreateAxaptaRecord(tableName));
{
// Provide values for each of the AddressState record fields.
axRecord.set_Field("NAME", "MyState");
axRecord.set_Field("STATEID", "MyState");
axRecord.set_Field("COUNTRYREGIONID", "US");
axRecord.set_Field("INTRASTATCODE", "");
// Commit the record to the database.
axRecord.Insert();
}
}
catch (Exception e)
{
Console.WriteLine("Error encountered: {0}", e.Message);
// Take other error action as needed.
}
Thursday, December 9, 2010
Creating Free Text Invoice through X++ code
Job: Calling class from job to run the class
public void freeTextInvoicePostTestJob()
{
Dialog dialog;
DialogField dlgCustAcc;
DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1;
DialogField dlgLedgerAcc;
;
dialog = new Dialog("Free-Text Invoice");
dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table');
dlgCustAcc = dialog.addField(typeid(CustAccount));
dialogPeriodLengthGroup = dialog.addGroup('Ledger Table');
dlgLedgerAcc = dialog.addField(typeid(LedgerAccount));
if(dialog.run())
{
if(dlgCustAcc.value() && dlgLedgerAcc.value() != '')
FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value());
else
throw error(strfmt("Either CustAccount or LedgerAccount info is missing."));
}
}
Class: Which creates the free text invoice
class FreeTxtInvoiceCreatePost
{
}
static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount)
{
CustInvoiceTable custInvoiceTable;
CustInvoiceLine custInvoiceLine;
CustTable custTable;
LedgerTable ledgerTable;
CustPostInvoice custPostInvoice;
LineNum lineNum;
int i;
ttsbegin;
custTable = CustTable::find(_custAccount);
custInvoiceTable.initFromCustTable(custTable);
custInvoiceTable.insert();
ttscommit;
for(i=1; i<=5; i++)
{
ttsbegin;
ledgerTable = LedgerTable::find(_ledgerAccount);
custInvoiceLine.clear();
custInvoiceLine.initValue();
custInvoiceLine.LedgerAccount = ledgerTable.AccountNum;
custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);
custInvoiceLine.AmountCur = 10.00;
custInvoiceLine.Description = 'FreeTxIv' + int2str(i);
custInvoiceLine.TaxItemGroup = 'full';
custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
lineNum += 1;
custInvoiceLine.LineNum = lineNum;
custInvoiceLine.insert();
ttscommit;
}
}
public void freeTextInvoicePostTestJob()
{
Dialog dialog;
DialogField dlgCustAcc;
DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1;
DialogField dlgLedgerAcc;
;
dialog = new Dialog("Free-Text Invoice");
dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table');
dlgCustAcc = dialog.addField(typeid(CustAccount));
dialogPeriodLengthGroup = dialog.addGroup('Ledger Table');
dlgLedgerAcc = dialog.addField(typeid(LedgerAccount));
if(dialog.run())
{
if(dlgCustAcc.value() && dlgLedgerAcc.value() != '')
FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value());
else
throw error(strfmt("Either CustAccount or LedgerAccount info is missing."));
}
}
Class: Which creates the free text invoice
class FreeTxtInvoiceCreatePost
{
}
static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount)
{
CustInvoiceTable custInvoiceTable;
CustInvoiceLine custInvoiceLine;
CustTable custTable;
LedgerTable ledgerTable;
CustPostInvoice custPostInvoice;
LineNum lineNum;
int i;
ttsbegin;
custTable = CustTable::find(_custAccount);
custInvoiceTable.initFromCustTable(custTable);
custInvoiceTable.insert();
ttscommit;
for(i=1; i<=5; i++)
{
ttsbegin;
ledgerTable = LedgerTable::find(_ledgerAccount);
custInvoiceLine.clear();
custInvoiceLine.initValue();
custInvoiceLine.LedgerAccount = ledgerTable.AccountNum;
custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);
custInvoiceLine.AmountCur = 10.00;
custInvoiceLine.Description = 'FreeTxIv' + int2str(i);
custInvoiceLine.TaxItemGroup = 'full';
custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
lineNum += 1;
custInvoiceLine.LineNum = lineNum;
custInvoiceLine.insert();
ttscommit;
}
}
Thursday, October 28, 2010
AX: Getting list of Non AOT tables
Microsoft Dynamics AX,
Getting list of Non AOT tables,
select table_name
from information_schema.tables st
where st.table_name not in (select SQLNAME
from SQLDICTIONARY sd
where sd.FIELDID = 0
and sd.ARRAY=0
AND sd.FLAGS = 0)
and st.table_name <> 'SQLSYSTEMVARIABLES';
Getting list of Non AOT tables,
select table_name
from information_schema.tables st
where st.table_name not in (select SQLNAME
from SQLDICTIONARY sd
where sd.FIELDID = 0
and sd.ARRAY=0
AND sd.FLAGS = 0)
and st.table_name <> 'SQLSYSTEMVARIABLES';
Getting record counts for all tables in specific database
Getting list of record count of all tables in specific database,
Query:
sp_msforeachtable '
declare @rowcnt int
select @rowcnt=count(*) from ?
if (@rowcnt>0)
print "?" + str(@rowcnt)
'
Query:
sp_msforeachtable '
declare @rowcnt int
select @rowcnt=count(*) from ?
if (@rowcnt>0)
print "?" + str(@rowcnt)
'
Saturday, September 25, 2010
Subscribe to:
Posts (Atom)