19 December 2014

AX 2012 AOS load balancing and clustering

Dear Friends,

1. Install AOS with new TCP\ip port number and new wsdl port number
2. Start New AOS which is installed.
3. Create new client configuration with new AOS so you will find two configurations as follows
4. Goto administration > Setup > System > Cluster configuration
5.Press CTRL+N to create a new cluster.
6.Go to Map AOS instance cluster then select new AOS.
7.Click the Cluster name field to display a list of available clusters. Select the cluster that you want to add the AOS instance to.
8.Press CTRL+S to save your changes
9. If you want the AOS instance that you selected to function as a load balancer, select the Load balancer option.
as shown below


happy Daxing :-)

11 December 2014

Create new legal entity using X++ code in AX 2012

Hi Friends,
Below code snippet will help you to create new legal entities in AX 2012

static void CompanyUpload(Args _args)
{
OMNewLegalEntityViewModel oMNewLegalEntityViewModel = new OMNewLegalEntityViewModel();

oMNewLegalEntityViewModel.parmCompany("997");
oMNewLegalEntityViewModel.parmName("Test7");
oMNewLegalEntityViewModel.parmCountryRegion("IND");
oMNewLegalEntityViewModel.createLegalEntity();

info("Company has been created");
}

Happy Daxing..:-)

20 November 2014

Start Power Pivot in Microsoft Excel 2013 add-in for AX 2012 R3

Start Power Pivot in Microsoft Excel 2013 add-in

Then have to configure and establish the connect with AX 2012 R3 database - MicrosoftDynamicsAX.
Then select the list of table required to this Power Pivot.

Thanks
Happy Daxing

19 November 2014

AX 2012 R3 Manament reporter installation and configuration

Please click this link to check in YouTube video

After this video please follow the below steps.

After installation, you must open the Report Designer client and enter registration keys. After you have entered registration keys, additional configuration might be required before you can add report viewers or users. For information about how to configure Management Reporter,

Open the report designer and test the connection and set the default company and open the same in the AX-> GL->Reports->Management Reporter.

Thanks

Happy daxing:-)

Error When open Data Import \ Export parameters screen in AX 2012 R3


Assembly containing type Microsoft.Dynamics.AX.DMF.ServiceProxy.DmfEntityProxy is not referenced

object CLR object could not be created


Solution: I have got the same error. Please restart the AOS.

13 October 2014

Caching techniques in AX / Cache lookup

Dynamics AX Caching


Cache Location

Caches are used on both the client and the server. The Microsoft Dynamics AX runtime manages the cache by removing old records when new records are added to the cache.

Client Cache

A client-side cache can be used only by the client. The client cache is used when a select is executed from the client tier. If no record is found in the client cache, the client then searches the server cache for the record. If the record isn't located in the server cache, it's retrieved from the database. The maximum number of records maintained in a client cache is 100 records per table for a given company.

Server Cache

A server-side cache can be used by any connection to the server. The server cache is used when a select is executed on the server tier. If no record is found in the cache, it's retrieved from the database. The maximum number of records maintained in a server cache is 2,000 records per table for a given company.

Record Caching

Microsoft Dynamics AX database record caching is a performance-enhancing feature that helps avoid database access when it's not strictly necessary. Retrieving database records from memory instead of the database significantly speeds up data access. Caching can reduce the performance penalty for repetitively accessing the same database records.

Types of Caching

Caching is transparent to the application; however, it's important to know how caching works to optimize its performance in Microsoft Dynamics AX. Following are the types of caching:

Single-record
Set-based
Single-record caching has the following characteristics:

Defined at design time
Moves records to the cache based on the table's CacheLookup property and the type of SELECT statement that is used to retrieve the record


Set-based caching has the following characteristics:

Defined either at design time or in X++ code
Moves sets of records to the cache
Implemented either through the table's CacheLookup property or in code by using the RecordViewCache class
Single-Record Caching

Record caching is enabled for a table when all the following statements are true:

The CacheLookup property on the table is enabled by setting it to one of the following values:
· notInTTS
· Found
· FoundAndEmpty

The table's PrimaryIndex property is set to a unique index that exists on the table. The RecId index does not qualify as a caching index unless you set the table's PrimaryIndex property to this index.
The record buffer disableCache method has not been called with a parameter of true.
The fields in the table's unique index make up the caching key. A record is placed in the cache when the following criteria are met:

The table is cached by setting the CacheLookup property to notInTTS, Found, or FoundAndEmpty.
The SELECT statement that selects the records uses an equal operator (==) on the caching key. The fields in the WHERE clause of the SELECT statement match the fields in the index referenced by the table's PrimaryIndex property.
The table's CacheLookup property defines how and when records are cached as shown in the following table.

CacheLookup Property Value
Result
None
No data is cached or retrieved from the cache for this table.
This property value should be used for tables that are heavily updated or where it's unacceptable to read outdated data.
NotInTTS
All successful caching key selects are cached.
When in a transaction (after ttsBegin), no caches made outside the transaction are used. When inside a transaction, the record is read once from database and subsequently from cache. The record is select-locked when read in a transaction, which ensures that the record cached is not updated while the transaction is active.
A typical example of the NotInTTS property is the CustTable in the Microsoft Dynamics AX standard application. It's acceptable to read outdated data from the cache outside a transaction, but when data is used for validation or creating references, it is ensured that the data is real-time.
Found
All successful caching key selects are cached. All caching key selects are returned from the cache if the record exists there. A selectforUpdate in a transaction forces reading from the database and replaces the record in the cache.
This is typically used for static (lookup) tables, such as Unit, where the record usually exists.
FoundAndEmpty
All selects on caching keys are cached, including selects that are not returning data.
All caching key selects are returned from caching if the record exists there, or the record is marked as nonexistent in the cache. A selectforUpdate in a transaction forces reading from the database and replaces the record in the cache.
An example of FoundAndEmpty record caching is in the Discount table in the Microsoft Dynamics AX standard application. By default, the Discount table has no records. By using a FoundAndEmpty cache on this table, the keys that are queried for but not found are stored in the cache. Subsequent queries for these same non-existent records can be answered from the cache without a round trip to the database.
EntireTable
Creates a set-based cache on the server. The entire table is cached as soon as at least one record is selected from the table.


The Found and FoundAndEmpty caches cross transaction boundaries. The NotInTTS cache is newly created inside a transaction. This example, modified for the purposes of this topic, demonstrates how records are retrieved from the cache when the table's CacheLookup property is set to NotInTTS, and the PrimaryIndex property is set to a unique index on the AccountNum field.

static void NotInTTSCache(Args _args)
{
CustTable custTable;
;
// The query looks for records in the cache.
// If records don't exist, the query accesses the database.
select custTable
where custTable.AccountNum == '4000';
// The transaction starts.
ttsbegin;
// The cache is not used. The query accesses the database
// and records are placed in the cache.
select custTable
where custTable.AccountNum == '4000';

// The query uses the database because
// the forupdate keyword is used.
select forupdate custTable
where custTable.AccountNum == '4000';
// The query uses the cache and not the database.
select custTable
where custTable.AccountNum == '4000';
// The query uses the cache because
// the forupdate keyword was used previously.
select forupdate custTable
where custTable.AccountNum == '4000';

// The transaction is committed.
ttscommit;

// The query will use the cache.
select custTable
where custTable.AccountNum == '4000';
}
If the table CacheLookup property was set to Found or FoundAndEmpty, the first select statement inside the transaction (after the TTSBegin statement) would retrieve the record from the cache.



















Set-Based Caching

In Microsoft Dynamics AX, groups of records can be cached all at once with set-based caching. Set-based caching can be implemented in two ways:

At design time, by setting the table's CacheLookup property to EntireTable.
In code, by using the RecordViewCache class.

EntireTable Cache
*
When you set a table's CacheLookup property to EntireTable, all the records in the table are placed in the cache after the first select. This type of caching follows the rules of single record caching in which the SELECT statement WHERE clause fields must match those of the unique index defined in the table's PrimaryIndex property.

The EntireTable cache is located on the server and is shared by all connections to the Application Object Server (AOS). If a select is made on the client tier to a table that is EntireTable cached, it first looks in its own cache and then searches the server-side EntireTable cache. An EntireTable cache is created for each table for a given company. If you have two selects on the same table for different companies the entire table is cached twice.

Joins that include an EntireTable cached table are only performed against the cached copy when all tables participating in the join are EntireTable cached. Otherwise a database join is performed.

Important Note:

Avoid using EntireTable caches for large tables because once the cache size reaches 128 KB the cache is moved from memory to disk. A disk search is much slower than an in-memory search.

Flushing the Cache

An EntireTable cache is flushed whenever an insert, update, or delete is made to the table. At the same time, the AOS notifies other AOSs that their caches of the same table must be flushed. After the cache is flushed, a subsequent select on the table causes the entire table to be cached again. Therefore, avoid caching any table that's frequently updated. Regardless of when updates are made, EntireTable caches are flushed every 24 hours by the AOS.

RecordViewCache Cache
*
Set-based caching is implemented in code by using the RecordViewCache class. You must first create a record buffer using the nofetch statement and then pass the record buffer to the RecordViewCache class when it's instantiated.

The cache is created on the server and is only accessible by the process that creates the cache object. Once the cache is instantiated, all select statements are issued against the cache, as shown in the following

static void RecordViewCache(Args _args)
{
CustTrans custTrans;
RecordViewCache recordViewCache;
;
// Define records to cache.
select nofetch custTrans
where custTrans.AccountNum == '4000';

// Cache the records.
recordViewCache = new RecordViewCache(custTrans);

// Use cache.
select firstonly custTrans
where custTrans.AccountNum == '4000' &&
custTrans.CurrencyCode == 'USD';
}


Due to concurrency issues, the forUpdate keyword on the instantiating X++ SELECT statement should only be used when all of the records in the result set will be updated. Otherwise it's a better strategy to use select forUpdate only for the records that are to be updated.

The RecordViewCache class is used in a select when the select is from a table that's cached, the select statement doesn't participate in a join and the select WHERE clause matches the WHERE clause with which the RecordViewCache was instantiated.

The cache created by the RecordViewCache class stores records in a linked list. Therefore Microsoft Dynamics AX searches the cache sequentially for records that match the search criteria. If the SELECT statement contains an ORDER BY clause, a temporary index is placed on the cache and the runtime uses the index when searching records.

07 October 2014

Multi selected lookup in AX 2012

Hai,

Create a new form named as "MultiSelectLookup"
Add a string control set control properties: autodeclaration : Yes

\Forms\MultiSelectLookup\Methods\classDeclaration

public class FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl msctrl;

}

\Forms\MultiSelectLookup\Methods\init

// SysLookupMultiSelectCtrl is the class to construct multi select
public void init()
{
super();
msctrl = SysLookupMultiSelectCtrl::construct(element,StringEdit,queryStr(CustTable));// cust table is the query

}
// to show the selected values

\Forms\MultiSelectLookup\Designs\Design\StringEdit:StringEdit\Methods\modified

public boolean modified()
{
boolean ret;
container cont;
Counter counter;

ret = super();

cont = msctrl.getSelectedFieldValues();

for (counter = 1; counter <= conLen(cont); Counter++)
{
info(strFmt("%1",conPeek(cont,counter)));
}

return ret;
}

out put:

Infolog shows the selected values.

18 August 2014

AX 2012 Purchase order / sales order creation and invoicing through X++ / auto Purchase order posing

static void POAutoConfirmAndInvoice(Args _args)
{
PurchTable purchTable;
PurchLine purchLine;
VendTable vendTable = VendTable::find("US_TX_007");
AxPurchTable axPurchTable;
AxPurchLine axPurchLine;
PurchFormLetter purchFormLetter;
;

//Create Purchase order
purchTable.initFromVendTable(vendTable);

axPurchTable = axPurchTable::newPurchTable(purchTable);
axPurchTable.parmPurchaseType(PurchaseType::Purch);
axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);


axPurchTable.parmDeliveryDate(str2date("08/18/2014",213));
axPurchTable.parmAccountingDate(str2date("08/18/2014",213));
axPurchTable.parmPurchStatus(PurchStatus::Backorder);

axPurchTable.doSave();


purchLine.initFromPurchTable(purchTable);

axPurchLine = AxPurchLine::newPurchLine(purchLine);
axpurchLine.parmItemId("D0003");
axpurchLine.parmInventDimId('000458');
axPurchLine.parmPurchQty(10);
axPurchLine.parmPurchPrice(100);
axPurchLine.doSave();

//PO confirmation
purchTable = axPurchTable.purchTable();
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetter.update(purchTable, strFmt("Inv_%1", purchTable.PurchId));

// PO invoicing
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable, strFmt("Inv_%1", purchTable.PurchId));
info(strFmt("purchase order %1 invoiced",purchTable.PurchId));

}
===============================================================================

static void SOAutoConfirmAndInvoice(Args _args)
{
SalesTable salesTable;
SalesLine salesLine;
CustTable custTable= CustTable::find("US-004");
AxSalesTable axsalesTable;
AxSalesLine axSalesLine;
SalesFormLetter salesFormLetter;
;

//Create Sales order

salesTable.initFromCustTable();

axsalesTable = AxSalesTable::newSalesTable(salesTable);
axsalesTable.parmCustAccount("US-004");
axsalesTable.parmSalesType(SalesType::Sales);

axsalesTable.parmDocumentStatus(DocumentStatus::Confirmation);

axsalesTable.parmDeliveryDate(str2Date("08/18/2014",213));
axsalesTable.parmSalesStatus(SalesStatus::Backorder);

axsalesTable.doSave();

salesLine.initFromSalesTable(salesTable);

axSalesLine = AxSalesLine::newSalesLine(salesLine);
axSalesLine.parmItemId("D0003");
axSalesLine.parmInventDimId("000458");
axSalesLine.parmCurrencyCode("USD");
axSalesLine.parmSalesQty(2);
axSalesLine.parmSalesPrice(20.00);
axSalesLine.doSave();



//SO confirmation
salesTable = axSalesTable.salesTable(salesTable);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
salesFormLetter.update(salesTable);

// SO invoicing
salesFormLetter = salesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.update(salesTable);

}

11 June 2014

How to Debug RDP class SSRS report in AX 2012

1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase

2. Temp table properties should be

(a) Table type : Regular instead of tempDB

(b) Created by : Yes

(c) Created Transaction Id : Yes

3. In process report of the class add this line in Temporarytablename.setConnection(this.parmUserConnection());

19 May 2014

Financial default dimension in AX 2012

static void DEV_Dimension(Args _args)

{

CustTable custTable = CustTable::find("000007");

DimensionAttributeValueSetStorage dimStorage;

Counter i;

dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);

for (i=1 ; i<= dimStorage.elements() ; i++) { info(strFmt("%1 = %2", DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name, dimStorage.getDisplayValueByIndex(i))); } } ===================== static void DefaultDimenstionValue(Args _args) { CustTable custTable = CustTable::find("000007"); DimensionAttributeValueSetStorage dimStorage; Counter i; DefaultDimensionView defaultDimensionView;


select defaultDimensionView where defaultDimensionView.DefaultDimension == custTable.DefaultDimension;
info(strFmt("Dimenstion: %1 Name is : %2",defaultDimensionView.DisplayValue, defaultDimensionView.Name));
}

29 April 2014

Refresh the Form Data from another Form in AX 2009/ 2012

HI Folks,

Hope this will help you..In the following scenario we have to insert records in CustGroup from the child form.
As shown below. Can be achieve by using FormDataSource or FormObjectSet classes.

Note: formDataSource = element.args().record().dataSource(); // _object = element.args().record().dataSource();

Step 1 create a button in cust goup form

Step 2 In this button write the below code where you are calling a form and passing the record.


void clicked()
{
Args args;
FormRun formRun;

super();

args = new args("CustGroupCreate");
formRun = new FormRun(args);
args.record(CustGroup);

formRun.init();
formRun.run();
formRun.wait();
}

Step 3 Create new form called "CustGroupCreate" as shown below with unbounded controls.


Step 4 Declare a variable for FormDataSource class in as shown below :

public class FormRun extends ObjectRun
{
FormDataSource formDataSource; // FormObjectset _object;
CustGroup localCustGroup;

}
Step 5 Override a init() method and write the below code to get the parent form datasource.

public void init()
{
super();
if(element.args().record())
formDataSource = element.args().record().dataSource(); // _object = element.args().record().dataSource();
}

Step 6 Take another override method close()and code for insertion and using the formDataSource variable refresh the parent Data Source as shown below. Once you you insert a record and close the form that will refresh the parent Data source immediately.

public void close()
{
super();

localCustGroup.CustGroup = CustGroup_CustGroup.text();
localCustGroup.Name = CustGroup_Name.text();
localCustGroup.PaymTermId = CustGroup_PaymTermId.text();
localCustGroup.insert();

formDataSource.research(true); // _object.research(true);
}

25 April 2014

Hi, Friends,

below code will helps to convert the sting to barcode, you just pass the string type and get the barcode



str 128 Convert2Code128(str _str)
{
BarCode barCode1 = BarCode::construct(barCodeType::Code128);
;
barCode1.string(true, strUpr(_str));
barCode1.encode();
return barCode1.barcodeStr();
}


then setup the properties as below:


10 April 2014

UTCDateTime to Date conversion and date comparition

HI Guys,This may be useful for you.

Date _date;

_date = DateTimeUtil::date(testTable.CraetedDateTime); // _time = DateTimeUtil::Time(testTable.CraetedDateTime); to get time

if(_date <= 31\12\2010) // dd\mm\yyyy
// do some thing


Thanks
Sunil

28 March 2014

Split the string value by using saperatror in AX

static void StringSplitter(Args _args)
{
GeneralJournalAccountEntry generalJournalAccountEntry;
TextBuffer buffer;
str value;
Counter cnt;

value = "1000-524-457-524";
//select generalJournalAccountEntry;
buffer = new TextBuffer();
buffer.setText(value);//generalJournalAccountEntry.LedgerAccount);

while (buffer.nextToken(0, '-'))
{
cnt++;

if(cnt == 1)
info (strFmt("first %1",buffer.token()));
if(cnt == 2)
info (strFmt("two %1",buffer.token()));
if(cnt == 3)
info (strFmt("three %1",buffer.token()));
if(cnt == 4)
info (strFmt("four %1",buffer.token()));

}
}

How to get Ledger dimension values individually in AX 2012

static void IndividualDimensionValuesUsingView(Args _args)
{
GeneralJournalAccountEntry generalJournalAccountEntry; //Table that stores ledger transactions
DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
DimensionAttribute dimAttr; //Main dimension attribute table
int i;

setPrefix("Ledger dimension breakup");
while select generalJournalAccountEntry
{
i++;
if (i > 100)
break;

setPrefix(int2str(i) + ". " + DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension).DisplayValue);
while select DisplayValue from dimAttrView
where dimAttrView.ValueCombinationRecId == generalJournalAccountEntry.LedgerDimension
join BackingEntityType from dimAttr
where dimAttr.RecId == dimAttrView.DimensionAttribute
{
switch (dimAttr.BackingEntityType)
{
case tableNum(DimAttributeMainAccount):
info(strFmt("Main Account: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeOMBusinessUnit):
info(strFmt("Business Unit: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeCustTable):
info(strFmt("Customer: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeOMDepartment):
info(strFmt("Department: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeHcmWorker):
info(strFmt("Worker: %1", dimAttrView.DisplayValue));
break;
}
}
}

}

14 March 2014

Deploying Models in Test and Production environment process

Set query Range for Existing report in while running in class PrintMedium settings for Report in class

Method()
{
Args args;
ReportRun reportRun;
str reportName = "ReportNameTest";
str myPath;
int i;
TransDate td;
TransDate vd;
str rangeDate;
;
i = 1;
td = systemDateget();
args = new Args(reportName);
args.caller(reportRun);

reportRun = new reportRun(args);
reportRun.query().interactive(false);
reportRun.query().dataSourceTable(tablenum(TableNmae)).addRange(fieldNum(TableNmae,FeildNmae)).value(SysQuery::value(td));
reportRun.report().interactive(false);

reportRun.setTarget(printMedium::File);
reportRun.printJobSettings().setTarget(PrintMedium::File);
reportRun.printJobSettings().preferredTarget(PrintMedium::File);
reportRun.printJobSettings().format(PrintFormat::PDF);
reportRun.printJobSettings().warnIfFileExists(false);
reportRun.printJobSettings().suppressScalingMessage(true);
pdfFileName = @"\\AXTESTDEV1\D$\Demo\Test.pdf";
reportRun.printJobSettings().fileName(pdfFileName);

reportRun.init();
reportRun.run();
}

06 March 2014

AX 2012 SSRS RDP Class

[SRSReportQueryAttribute(querystr(CustTransQuery))]
public class CustTransdemoDP extends SRSReportDataProviderBase
{
CustTransDemoTmp custTransDemoTmp;
CustTable custTable;
CustTrans custTrans;
AmountCur amountCur;
Voucher voucher;
CustGroupId custGroup;
TransDate transDate;

}
=================
[SRSReportDataSetAttribute(tableStr(CustTransDemoTmp))]
private CustTransDemoTmp getCustTransTmp()
{
select custTransDemoTmp;

return custTransDemoTmp;
}
======================
private void inserrtIntoCustTransTmp()
{
custTransDemoTmp.CustGroup = custTable.CustGroup;
custTransDemoTmp.AmountCur = custTrans.AmountCur;
custTransDemoTmp.Voucher = custTrans.Voucher;
custTransDemoTmp.TransDate = custTrans.TransDate;
custTransDemoTmp.insert();
}
=======================
[SysEntryPointAttribute]
public void processReport()
{
QueryRun queryRun;

queryRun = new QueryRun(this.parmQuery());

while (queryRun.next())
{
custTable = queryRun.get(tablenum(CustTable));
custTrans = queryRun.get(tablenum(CustTrans));

amountCur = custTrans.AmountCur;
voucher = custTrans.Voucher;
custGroup = custTable.CustGroup;
transDate = custTrans.TransDate;

this.inserrtIntoCustTransTmp();
}
}

27 February 2014

Microsoft Dynamics AX 2012 R3 technical features

Hi Guys, There are some major changes in AX 2012 R3 as follows

1.Automated deployment of AX 2012R3 in Windows Azure
2.Building Microsoft AX services integration with the Microsoft Windows Azure Service Bus
3.Data synchronization to multiple instances of Microsoft Dynamics AX
4.Optimizing the performance of Microsoft Dynamics AX deployment
5.Create Microsoft Dynamics AX builds using the new X++ server-side parallel compiler


Happy Daxing.. :-)

06 February 2014

Write data to text file in AX 2012 and AX 2009

static void writeDataToTxt(Args _args)
{

CustTable custTable;
BinData binData;
TextBuffer textBuffer;
;

textBuffer = new TextBuffer();
textBuffer.setText('');

while select custTable
{
textBuffer.appendText(strfmt('%1\r\n',custTable.AccountNum));
}

textBuffer.getText();

binData = new BinData();
binData.setStrData(textBuffer.getText());
binData.saveFile(@"C:\fileOUt\test.txt");

}

01 February 2014

Queries query classes example in AX 2012

static void Query_cntRecords(Args _args)
{
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource qbd;
int64 iCountRecords;
;

qbd = query.addDataSource(tablenum(CustTable));
queryRun = new QueryRun(query);
iCountRecords = SysQuery::countTotal(queryRun);

info(strfmt("Total Records in Query %1", SysQuery::countTotal(queryRun)));

}

Dialog Runbase Example in AX 2012

class Runbase_Example extends RunBase
{
TransDate fromDate,toDate;
CustAccount custAccount;

DialogField dlgFromDate,dlgToDate,custDldField;

#define.CurrentVersion(1)
#localmacro.CurrentList
fromDate,toDate
#endmacro
}
protected Object dialog()
{
DialogRunbase dialog;

dialog = super();
dialog = super();
custDldField = dialog.addFieldValue(extendedTypeStr(CustAccount),custAccount);
dlgFromDate = dialog.addFieldValue(extendedTypeStr(TransDate),fromDate);
dlgToDate = dialog.addFieldValue(extendedTypeStr(TransDate),toDate);

return dialog;
}
public boolean getFromDialog()
{
boolean ret;

ret = super();
custAccount = custDldField.value();
fromDate = dlgFromDate.value();
toDate = dlgToDate.value();

return ret;
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
public static void main(Args args)
{
Runbase_Example runb = new Runbase_Example();

if(runb.prompt())
{
runb.run();
}
}

create new number sequence by x++ code in AX 2012

static void DemoNumberSeq(Args _args)
{
NumberSeq numberSeq;
Str salesId;
ttsbegin;
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
salesId = numberSeq.num(); 
ttscommit;
info(strFmt("%1",salesId));
}

How it works
1.NumberSeq Table act as master table for numberseq code , which stores
format to be generated , next sequence etc.
2.NumberSequenceReferences stores all the references and their corresponding
numberseq codes.
3.As shown in the above code , NumberSeq class needs numberseqreference ,
i,e "EDT. Unique Id for the Process " So first get the references by
passing an EDT as parameter to the findReference method of numberseqreference
class.Than you can call numberSeq.num() method to generate the number
for you.
4.Use NumberSeqFormHandler class if you want to use the numbersequencs on form.

30 January 2014

How to Create EDT relation in AX 2012

setp 1. First create New Edit.

setp 2.Create New Table Name is "TestParent" Table

then drag and drop the newly created Edt in "TestParent" Table

setp 3.Create Index for new created EDT in "TestParent" Table

the properties on index is AllowDuplicates to No and Alternativekey to Yes

setp 4.then select the "TestParent" Table and right click on it select properties sheet set the "primary index" property i.e the newly created index

setp 5.Then go to EDT and right click on it ,select property sheet then go to "Reference Table" property Set it to "TestParent" Table Name

setp 6.Create a Second Table i.e child Table

setp 7.Then Drag and drop the EDT

then it will prompt the one dialog box

in that dialog box click Yes button then lookup will created on that field.

Happy Daxing... :-)

09 January 2014

Cannot execute a data definition language command on (). The SQL database has issued an error. ion AX 2009 force to DB synchronize

Use the below job to to find out the tables for synchronize errors

static void DB_Synchronize_force(Args _args)
{
Dictionary dict;
int idx, lastIdx, totalTables;
TableId tableId;
Application application;
SysOperationProgress progress;
StackBase errorStack;
ErrorTxt errorTxt;
;

application = new Application();
dict = new Dictionary();
totalTables = dict.tableCnt();
progress = new SysOperationProgress();
progress.setTotal(totalTables);
progress.setCaption("@SYS90206");
errorStack = new StackBase(Types::String);

lastIdx = 0;
try
{
for (idx = lastIdx+1; idx <= totalTables; idx++)
{
tableId = dict.tableCnt2Id(idx);
progress.setText(dict.tableName(tableId));

lastIdx = idx;
application.dbSynchronize(tableId, false, true, false);
progress.incCount();
}
}
catch (Exception::Error)
{
errorTxt = strFmt("Error in table '%1' (%2)", tableId, dict.tableName(tableId));
errorStack.push(errorTxt);
retry;
}

setPrefix("@SYS86407");
errorTxt = errorStack.pop();
while (errorTxt)
{
error(errorTxt);
errorTxt = errorStack.pop();
}
}

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-...