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;
}
}

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 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)
'

Saturday, September 25, 2010

Website desing

For any website design contact visit below address,
http://www.whizkidsoft.com/

AX 2009 - Getting List of Object Ids and its Name from AOT

Getting list of Objects Id and its Name from AOT objects like Classes, Tables, EDT etc.

static void findObjectIdNames(Args _args)
{
Dictionary dictionary;
ClassId ClassId;
TableId tableId;
ClassName className;
TableName tableName;
;

dictionary = new Dictionary();
do
{
//For Classes
ClassId = dictionary.classNext(ClassId);
className = dictionary.className(ClassId);

info(strfmt("%1 - %2",int2str(classId), className));

}while (ClassId)
}

Note: Use distionary class for finding id and names of tables, classes, EDT, enum, security keys etc.

Tuesday, June 22, 2010

AX V3 to AX 2009 upgradation.

Which are the equivalent tables in AX 2009 for V3 tables SalesPickingListTable and CustPickingListJour
Thanx,
Ambanna Yatnal