Posts

Showing posts from 2013

Update Customer/Vendor Financial dimensions in AX 2012

static void ImportCustomerDimension( Args _args) { AsciiIO asciiIO; Filename filename; NoYesId skipFirstLine; Container line; Dialog dialog; DialogField dialogFileName, dialogSkipFirstLine; DimensionAttribute dimAttr; DimensionAttributeSetItem dimAttrSetItem; DimensionEnumeration dimensionSetId; Container combinedContainer; CustTable custTable; CustAccount custAccount; Counter counter; DimensionAttributeValue dimAttributeValue; //Dialog dialog = new Dialog ( "Import Default Dimension" ); dialogFileName = dialog.addField(extendedTypeStr(Filenameopen), "File name" ); dialogSkipFirstLine = dialog.addField(extendedTypeStr( NoYesId ), "Skip first line" ); if (dialog.run()) { file...

Get Segments from Segment Entry Control in LedgerDimension

Image
  We can get the different segments present in segment entry control. In the below example i am using GL - Inquiries - Voucher transactions screen.  On this screen lets try to get Main Account segment & display in the grid. Write a display method on  GeneralJournalAccountEntry table.  public display DimensionValue displayMainAcct() {     #define.MainAccount('MainAccount')     DimensionStorage        dimensionStorage;     int                     segmentCount, segmentIndex;     DimensionStorageSegment segment;     DimensionValue          segmentName, MainAccount, segmentValue, MainAcctValue;     container               segments;     dimensionStorage = DimensionStorage::findById(this.LedgerDimension);      ...

Create Vertical & Horizontal splitter on a Form

Image
Create a Form in AOT, in form class declaration add following code SysFormSplitter_Y               formSplitterHorizontal; SysFormSplitter_X               formSplitterVertical; Design the form with groups as shown below with properties of  CtrlSplitHorizontal , CtrlSplitVertical groups. On the form init method add following code formSplitterHorizontal = new SysFormSplitter_Y(CtrlSplitHorizontal, GroupTable, this);     formSplitterVertical = new SysFormSplitter_X(CtrlSplitVertical, GroupLineLeft, this); On the  CtrlSplitHorizontal  override the following methods  public int mouseDown(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift) {     super(_x, _y, _button, _Ctrl, _Shift);     return formSplitterHorizontal.mouseDown(_x, _y, _button, _ctrl, _shift); } public int mouseMove(int _x, int _y, int _but...

Build Financial dimension based on other dimension values in AX 2012

Image
From the above example, If you want to get the CostCenter (first 4 chars)  & deparment (2-3 chars) from ExpensePurpose, we have to customize some standard classes to achieve it. DimensionDefaultingControllerBase class manages the display, user interaction and storage of default dimension check boxes, combo boxes and values. In DimensionDefaultingControllerBase class customize the LoadAttibuteValueSet method to create the CostCenter & Department. The _dimAttributeValueSetId is the DefaultDimension recId which has the value user entered in ExpensePurpose field. You can write separate method to retrieve the details of Financial Dimension from _dimAttributeValueSetId  & prepare your own DefaultDimension recId and reassign to _dimAttributeValueSetId.

Get Sales Order Totals using X++

Image
We can make use of standard class SalesTotals to get the Totals subform related fields data through X++. SalesTotals returns a container with lot of fields in it, Some of them i have listed below. static void SalesOrderTotal(Args _args) {     SalesTotals     salesTotals;     SalesTable      salesTable;     container       displayFields;     str             totalTax,  amountInclTax, amountWithoutTaxTxt;     AmountMST       amountWithoutTax;          salesTable = salesTable::find('S000076');     salesTotals  =  SalesTotals::construct(salesTable, salesUpdate::All);     salesTotals.calc();     displayFields =  salesTotals.displayFieldsCurrency(salesTotals.currencyCode());     amountWithoutTaxTxt     = conpeek(displayFields, ...

Create a custom lookup with multiple data sources on form using X++

Open the form on which you want to create a custom lookup. Go the data source - fields, select field and override the lookup method. Following code will help you in creating custom lookup using SysTableLookup with multiple data sources.  public void lookup(FormControl _formControl, str _filterStr) {      SysTableLookup            sysTableLookup;      Query                          query;      QueryBuildDataSource  qbds1, qbds2;      ;      sysTableLookup = SysTableLookup::newParameters(tablenum(table1),_formcontrol);      query = new Query();      qbds1 = query.addDataSource(tablenum(table1));    ...

Creating a Dialog using X++

Static Void DialogExample(Args _args) {         Dialog                  dialog ;         DialogGroup         dialogGrp;         DialogField           dlgCustAccount;       DialogField           dlgCustName;       CustAccount         custAcct;       CustName            custName;       ;       dialog.Caption("Customer information");       dialogGrp = dialog.AddGroup("Setup");     ...

Reading CSV file using X++

Static void ReadCSVFile(Args _args)   {      #File      IO                                     iO;      FilenameOpen                fileName = "C:\\abcd.csv";      Container                        con;      boolean                           firstRecordHdr = true;      Str                             ...