I am sharing the excellent article of Alex Anikiev, PhD, MCP  about import Sales order in X++ code with article link
Purpose: The purpose of this document is to illustrate how to write a required minimum X++ code in Microsoft Dynamics AX 2012 in order to import Sales orders.
Challenge: Data model changes in Microsoft Dynamics AX 2012 related to high normalization and introduction of surrogate keys made some imports more complex. However the structure of tables comprising Sales order header/lines didn’t change. Please note that after you import Sales orders you may need to perform full/partial Physical and/or Financial update if required (for example, for Purchase orders already in execution).
Solution: Appropriate tables buffers (SalesTable, SalesLine) will be used when writing X++ code in Microsoft Dynamics AX 2012 in order to import Sales orders. Alternatively AxBC classes may be used instead of table buffers.
Data Model:
Table Name
Table Description
SalesTable
The SalesTable table contains all sales order headers regardless of whether they have been posted.
SalesLine
The SalesLine table contains all sales order lines regardless of whether they have been posted.
InventDim
The InventDim table contains values for inventory dimensions.
Data Model Diagram:
<![if !vml]><![endif]>
 
Development:
ttsBegin: Use ttsBegin to start a transaction.
clear: The clear method clears the contents of the record.
initValue: The initValue method initializes the fields of the record.
initFrom*: The initFrom* methods usually populate the fields of the child record based on the fields on the parent record. Example is initFromSalesTable method on SalesLine table.
validateWrite: The validateWrite method checks whether the record can be written.
write: The write method writes the record to the database.
insert: The insert method inserts the record into the database.
doInsert: The doInsert method inserts the record into the database. Calling doInsert ensures that any X++ code written in the insert method of the record is not executed. Calling insert always executes the X++ code written in theinsert method of the record.
ttsCommit: Use ttsCommit to commit a transaction.
Source code:
static void SalesOrdersXppImport(Args _args)
{
    #define.Customer(“US-001″)
    #define.DeliveryDate(“1/1/2014″)
    #define.ItemId(“M0001″)
    #define.Qty(10)
    #define.Unit(“ea”)
    SalesTable      salesTable;
    SalesLine       salesLine;
    InventDim       inventDim;
    try
    {
        ttsbegin;
        //Order header
        salesTable.clear();
        salesTable.initValue(SalesType::Sales);
        salesTable.SalesId = NumberSeq::newGetNum(SalesParameters::numRefSalesId()).num();
        salesTable.DeliveryDate = str2Date(#DeliveryDate, 213);
        salesTable.CustAccount = #Customer;
        salesTable.initFromCustTable();
        if (salesTable.validateWrite())
        {
            salesTable.insert();
            //Order line
            inventDim.clear();
            inventDim.InventSiteId = ”1″;
            inventDim.InventLocationId = ”12″;
            salesLine.clear();
            salesLine.initValue(salesTable.SalesType);
            salesLine.initFromSalesTable(salesTable);
            salesLine.ItemId = #ItemId;
            salesLine.initFromInventTable(InventTable::find(#ItemId));
            salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
            salesLine.SalesQty = #Qty;
            salesLine.RemainSalesPhysical = salesLine.SalesQty;
            salesLine.SalesUnit = #Unit;
            salesLine.QtyOrdered = salesLine.calcQtyOrdered();
            salesLine.RemainInventPhysical = salesLine.QtyOrdered;
            salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId));
            if (salesLine.validateWrite())
            {
                salesLine.insert();
            }
            else
                throw error(“Order line”);
        }
        else
            throw error(“Order header”);
        ttscommit;
    }
    catch
    {
        error(“Error!”);
        return;
    }
    info(“Done!”);
}
Result:
 
Please note that I assign SalesId programmatically from Number sequence
 
Product – Sales price
Sales order header
 
Sales order lines
 
Packing Slip
 
Invoice
 
Inventory transactions
Physical Voucher
 
Financial Voucher
 
Note: Microsoft Dynamics AX 2012 Demo Data (Company USMF) was used for this example
 
Version: Microsoft Dynamics AX 2012 RTM, R2
 
Summary: In this document I explained how to write a required minimum X++ code in Microsoft Dynamics AX 2012 in order to import Sales orders. Appropriate table buffers were used when writing X++ code in Microsoft Dynamics AX 2012. This approach can be very handy for POC’s or in situation with always changing requirements. You can also use Microsoft Dynamics AX Excel Add-in to import relatively small amounts of data. Please consider using DIXF (Data Import Export Framework) for import of significant amounts of data when performance is an important consideration. DIXF (Data Import Export Framework) provides a standard template for import of Sales orders.
Author: Alex Anikiev, PhD, MCP

{ 0 comments }

Recently I found the training session for new features of dynamics Ax 2012 R3 on Channel 9 website.

The important features of Dynamics Ax 2012 R3 are Warehouse management and Transportation management.  Presenters described these feature in brief and very precisely.  You can explore these features on below link of Channel 9.

http://channel9.msdn.com/Series/Microsoft-Dynamics-AX-2012-R3-Training

{ 0 comments }

I just saw the R3 demo VM. There is Lot of new features.  The major feature Include

  • Forecasting.
  • Budgeting
  • Transportation management
  • A wireless client for warehouse.
  • Retail Module has number of changes.

Let’s see small detail which I just collected.

 

  • Demand Planning – New Sales Forecasting Tool
    In Dynamics AX 2012 R3 a new Sales forecasting Tool giving which provide the more accurate for forecast.
  • Budget Planning - New tool for Budget Preparation 
    A budget planning include in Dynamics Ax R3 which will more standard to support the budgeting process.
  • Now Budget allocation based on allocation basis rules
  • Improved process flexibility and control by default and locked dimension values on certain type of budget plans
  • Evaluation of different scenarios for what-if analysis

 

  • Improved Warehouse Management functionality
    The warehouse management functionality enhanced to support for scanners, wave picking, license plates and process are more improve the warehouse.
  • Improved Inventory Control
  • Embedded Radio Frequency
  • Improved Inbound & Outbound Warehouse Operations

 

  • Transportation Management – New module for Shipment Planning and Control
    In transportation management, a new module that supports planning and packing containers, vehicles routes freight rates booking and billing, this will very important to enhancement for supply chain.
  • Rate, Route and Load Planning
  • Freight Reconciliation

 

Retail

  • A new and Windows 8 Tablet Point of Sales (POS) and Mobile POS.
  • A loyalty programs across legal entities and tiering of customer as well as enhanced gift card support.
  •  There are enrichments in pricing and promotions, assortment and catalog, BI and reporting and mark downs enhancements helping optimize revenue.

 

 

For developer or technical point of

  • a new compiler in Dynamics AX builds in the context of multiple developments integration.
  • A strong TFS Version Control support, which has previous version has problems.

 

References:

Here are some reference and  articles I found

A great article about compiler enhancement in Dynamics Ax 2012 R3 http://axwonders.blogspot.com/2014/03/hi-there-i-hope-everybody-is-doing.html

 

 

A detail article about Project management functionality enhancement in Dynamics Ax 2012 R3

http://sandeepchaudhury.wordpress.com/2014/01/26/enhancements-to-project-planning-functionality-in-ax-2012-r2-cu7/

 

There is registration going on for Webinar for Dynamics Ax 2012 R3 visit following link

https://presentations.inxpo.com/Shows/microsoft/4-10-14/Registration/Registration.html?AffiliateKey=21572&AffiliateData=

 

 

References : http://www.mwdata.dk/news/new-exciting-features-for-dynamics-ax-2012-coming-up/

http://blogs.msdn.com/b/dax/archive/2013/11/05/microsoft-dynamics-ax-2012-r3-a-preview.aspx

http://blog.encorebusiness.com/new-features-microsoft-dynamics-ax-2012-r3/

http://blog.encorebusiness.com/new-features-microsoft-dynamics-ax-2012-r3/

{ 0 comments }

Purpose: The purpose of this document is to illustrate how to write X++ code in Microsoft Dynamics AX 2012 in order to import Products and Released products.
Challenge: Data model changes in Microsoft Dynamics AX 2012 related to high normalization and introduction of surrogate keys made some imports more complex. In order to create a product in Microsoft Dynamics AX 2012 both product definition and released product information will have to be provided. Please note that in Dynamics AX 2012 Rich Client product definition is automatically created when released product is created using decentralized approach.
Solution: Appropriate tables buffers (EcoResProduct, EcoResDistinctProduct, InventTable, etc) will be used when writing X++ code in Microsoft Dynamics AX 2012 in order to import Products and Released products. Alternatively AxBC classes may be used instead of table buffers.
Assumption: The assumption is that appropriate reference data such as item groups, etc. was created in advance.
Data Model:
Table Name
Table Description
EcoResProduct
The EcoResProduct table stores products and is the base table in the products hierarchy.
EcoResProductIdentifier
The EcoResProductIdentifier table contains a product identification that is available for users.
EcoResDistinctProduct
The EcoResDistinctProduct table stores products.
EcoResStorageDimensionGroup
The EcoResStorageDimensionGroup table contains information about a storage dimension group.
EcoResTrackingDimensionGroup
The EcoResTrackingDimensionGroup table contains information about a tracking dimension group.
EcoResStorageDimensionGroupProduct
The EcoResStorageDimensionGroupProduct table contains information about the associations between products and storage dimension groups.
EcoResTrackingDimensionGroupProduct
The EcoResTrackingDimensionGroupProduct table contains information about the associations between products and tracking dimension groups.
EcoResStorageDimensionGroupItem
The EcoResStorageDimensionGroupItem table contains information about the associations between items and storage dimension groups.
EcoResTrackingDimensionGroupItem
The EcoResTrackingDimensionGroupItem table contains information about the associations between items and tracking dimension groups.
InventTable
The InventTable table contains information about items.
InventTableModule
The InventTableModule table contains information about purchase, sales, and inventory specific settings for items.
InventItemLocation
The InventItemLocation table contains information about items and the related warehouse and counting settings. The settings can be made specific based on the items configuration and vary from warehouse to warehouse.
InventItemSalesSetup
The InventItemSalesSetup table contains the default settings for items, such as site and warehouse. The values are related to sales settings.
InventItemInventSetup
The InventItemInventSetup table contains the default settings for items, such as site and warehouse. The values are related to inventory settings.
InventItemPurchSetup
The InventItemPurchSetup table contains the default settings for items, such as site and warehouse. The values are related to purchase settings.
InventItemSetupSupplyType
The InventItemSetupSupplyType table contains information about the sourcing of items.
InventModelGroupItem
The InventModelGroupItem table contains information about the associations between items and item model groups.
InventItemGroupItem
The InventItemGroupItem table contains information about the associations between items and item groups.
InventDim
The InventDim table contains values for inventory dimensions.
 
Data Model Diagram:
<![if !vml]><![endif]>
Zoom
Red area highlights tables forming Products and Product Masters data model
Green area highlights tables forming Released Products data models
Blue area highlights tables implementing Product Dimensions data model
 
Development:
ttsBegin: Use ttsBegin to start a transaction.
clear: The clear method clears the contents of the record.
initValue: The initValue method initializes the fields of the record.
initFrom*: The initFrom* methods usually populate the fields of the child record based on the fields on the parent record. Example is initFromEcoResProduct method on InventTable table.
validateWrite: The validateWrite method checks whether the record can be written.
write: The write method writes the record to the database.
insert: The insert method inserts the record into the database.
doInsert: The doInsert method inserts the record into the database. Calling doInsert ensures that any X++ code written in the insert method of the record is not executed. Calling insert always executes the X++ code written in theinsert method of the record.
ttsCommit: Use ttsCommit to commit a transaction.
Source code:
 
Products and Released products
 
static void ProductsXppImport(Args _args)
{
    #define.ProductNum()
    #define.SearchName()
    #define.StorageDim()
    #define.TrackingDim()
    #define.ItemId()
    #define.NameAlias()
    #define.ModelGroup()
    #define.ItemGroup()
    EcoResDistinctProduct               ecoResDistinctProduct;
    EcoResProductIdentifier             ecoResProductIdentifier;
    EcoResStorageDimensionGroupProduct  ecoResStorageDimensionGroupProduct;
    EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
    InventTable                         inventTable;
    InventTableModule                   inventTableModule;
    InventItemSetupSupplyType           inventItemSetupSupplyType;
    EcoResStorageDimensionGroupItem     ecoResStorageDimensionGroupItem;
    EcoResTrackingDimensionGroupItem    ecoResTrackingDimensionGroupItem;
    InventModelGroupItem                inventModelGroupItem;
    InventItemGroupItem                 inventItemGroupItem;
    try
    {
        //Product
        ecoResDistinctProduct.clear();
        ecoResDistinctProduct.initValue();
        ecoResDistinctProduct.ProductType = EcoResProductType::Item;
        ecoResDistinctProduct.DisplayProductNumber = ”Alex”;
        ecoResDistinctProduct.SearchName = ”Alex”;
        if (ecoResDistinctProduct.validateWrite())
        {
            ecoResDistinctProduct.insert();
            ecoResProductIdentifier.clear();
            ecoResProductIdentifier.initValue();
            ecoResProductIdentifier.ProductNumber = ”Alex”;
            ecoResProductIdentifier.Product = ecoResDistinctProduct.RecId;
            ecoResProductIdentifier.insert();
            //Storage dimension group
            ecoResStorageDimensionGroupProduct.clear();
            ecoResStorageDimensionGroupProduct.initValue();
            ecoResStorageDimensionGroupProduct.Product = ecoResDistinctProduct.RecId;
            ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(“Con-Dim”).RecId;
            if (ecoResStorageDimensionGroupProduct.validateWrite())
            {
                ecoResStorageDimensionGroupProduct.insert();
            }
            //Tracking dimension group
            ecoResTrackingDimensionGroupProduct.clear();
            ecoResTrackingDimensionGroupProduct.initValue();
            ecoResTrackingDimensionGroupProduct.Product = ecoResDistinctProduct.RecId;
            ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(“Con-Dim”).RecId;
            if (ecoResTrackingDimensionGroupProduct.validateWrite())
            {
                ecoResTrackingDimensionGroupProduct.insert();
            }
            EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProduct.RecId, ”Alex”,”Alex”);
            //Released product
            inventTable.clear();
            inventTable.initValue();
            inventTable.initFromEcoResProduct(ecoResDistinctProduct);
            inventTable.ItemId = ”Alex”;
            inventTable.NameAlias = ”Alex”;
            if (inventTable.validateWrite())
            {
                inventTable.insert();
                //Inventory model group
                inventModelGroupItem.clear();
                inventModelGroupItem.initValue();
                inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                inventModelGroupItem.ItemId = inventTable.ItemId;
                inventModelGroupItem.ModelGroupId = ”FIFO”;
                inventModelGroupItem.ModelGroupDataAreaId = curext();
                inventModelGroupItem.insert();
                //Item group
                inventItemGroupItem.clear();
                inventItemGroupItem.initValue();
                inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                inventItemGroupItem.ItemId = inventTable.ItemId;
                inventItemGroupItem.ItemGroupId = ”Parts”;
                inventItemGroupItem.ItemGroupDataAreaId = curext();
                inventItemGroupItem.insert();
                //Extended product details – Inventory
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
                inventTableModule.insert();
                //Extended product details – Purchase
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
                inventTableModule.insert();
                //Extended product details – Sales
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
                inventTableModule.insert();
                //Warehouse items
                InventItemLocation::createDefault(inventTable.ItemId);
                //Supply type setup
                inventItemSetupSupplyType.clear();
                inventItemSetupSupplyType.initValue();
                inventItemSetupSupplyType.ItemId = inventTable.ItemId;
                inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
                inventItemSetupSupplyType.insert();
                //Product storage dimension group
                ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResDistinctProduct.RecId);
                if (ecoResStorageDimensionGroupProduct.RecId)
                {
                    ecoResStorageDimensionGroupItem.clear();
                    ecoResStorageDimensionGroupItem.initValue();
                    ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                    ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResStorageDimensionGroupItem.StorageDimensionGroup   = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
                    ecoResStorageDimensionGroupItem.insert();
                }
                //Product tracking dimension group
                ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResDistinctProduct.RecId);
                if (ecoResTrackingDimensionGroupProduct.RecId)
                {
                    ecoResTrackingDimensionGroupItem.clear();
                    ecoResTrackingDimensionGroupItem.initValue();
                    ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                    ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
                    ecoResTrackingDimensionGroupItem.insert();
                }
            }
        }
    }
    catch
    {
        error(“Error!”);
        return;
    }
    info(“Done!”);
}
Result:
Microsoft Dynamics AX 2012 – Product
Microsoft Dynamics AX 2012 – Released product
Note: Microsoft Dynamics AX 2012 Demo Data (Company CEU) was used for this example
 
Version: Microsoft Dynamics AX 2012 RTM
 
Summary: In this document I explained how to write X++ code in Microsoft Dynamics AX 2012 in order to import Products and Released products. Appropriate table buffers were used when writing X++ code in Microsoft Dynamics AX 2012. This approach allows getting better performance during the import comparing to usage of Microsoft Dynamics AX 2012 Excel Add-in. Also this approach is more flexible for extending in the case of not yet fully defined or changing business requirements. Please consider using Data Import/Export Framework (former DMF, Data Migration Framework) for import of significant amounts of data when performance is an important consideration. Data Import/Export Framework provides a standard template for import of Products.
AuthorAlex Anikiiev, PhD, MCP
Reference http://ax2012xppdataimport.blogspot.com/2013/03/microsoft-dynamics-ax-2012-xpp-products.html

{ 0 comments }

 

CustGroup – The CustGroup table contains a list of groups into

which customers can be added. Every customer must

specify a CustGroup with which it is associated.

VendGroup – The VendGroup table contains definitions of vendor

groups.

CustTable - The CustTable table contains the list of customers

for accounts receivable and customer relationship

management.

VendTable –  The VendTable table contains vendors for accounts

payable.

SalesTable  - The SalesTable table contains all sales order headers,

regardless of whether they have been posted or not.

PurchTable –  The PurchTable table contains all purchase order

headers, regardless of whether they have been posted

or not.

SalesLine  - The SalesLine table contains all sales order lines,

regardless of whether they have been posted or not.

PurchLine –  The PurchLine table contains all purchase order lines,

regardless of whether they have been posted or not.

- Reference

http://www.winfosoft.com/blog/microsoft-dynamics-ax/microsoft-dynamics-ax-%E2%80%93-what-tables-compose-the-order-tables-in-dynamics-ax#sthash.QnSkRhYt.dpuf

{ 0 comments }

The SSRS reports need a data source from where data can be fetched and displayed on the report. Since we are going to develop query based report therefore we will use an AOT query as a data source.

For creating report, First we have to create A AOT Query. For this we have A simple AOT query base on Bank Deposit table

BankDeposit table.

query

By Default there is no field selected under field.

fields

Click on it and set dynamic property to ‘YES’, so all possible filed will appear on table.

properties

You can see all the fields of the table.

tablefields

Now open Visual studio and create a new SSRS report named it as QueryBasedReport. Use this query as data source

reportproject

Now you need to create a data set, QueryBasedReportDS, that will refer to an AOT query created earlier. In data set properties set ‘Data Source Type’ to ‘Query’ and in query property select the AOT query SampleQuery created earlier.

datasetproperties

All the fields are visible under Fields node of QueryBasedReportDS.  These fields won’t be visible if you haven’t set ‘Dynamic’ property of Fields to ‘Yes’ in AOT query and you won’t be able to see any field on report. Now add an auto design by right clicking on Design node and name it Report. Drag the data set of your report “QueryBasedReportDS” to report design named ‘Report’.

company_name

Make sure that the table you are using has some records in it. If there is data in table and still you are unable to see records on report, you might need to do following steps.  Go to ‘Parameters’ node of your report ‘QueryBasedReport’.Right click on AX_ComapnyName and select properties. Set the value of the property ‘Visibility’ from Hidden to Visible and save the changes.Now right click on report design to preview it. Following dialog will appear. Enter AX_CompanyName ‘CEU’.

company_properties1

parameters

Now click on Report tab. Following report output will be shown.You can also view the developed report from browser using following url http://localhost/reports but before this you need to deploy the report on report sever.  This can be done by right clicking the solution in

reportoutput

visual studio and selecting deploy. default.

 

If this service is not started, start it. If it is already started, you need to restart it. After restarting the service, go to visual studio and deploy the solution. Your report is successfully deployed on the server.

Now you can see the report result from any browser. Go to http://localhost/Reports click on DynamicsAX folder and click on the report you want to run. In our case, it is QueryBasedReport.Report. If you can’t find any record, change the company name from DAT to CEU.

reportoutput

Now you can see data on the report.

Running report Inside Dynamics AX Client, you have to output menu item. Save following properties and save the changes.

 

menuitemproperties

You will see records on the report.

So these were the errors and solutions, I came across so far. I hope it helps. If you have encountered some more, please do share. Keep rocking :)

 

{ 0 comments }

Here is the code in X++:
public static void CustomerForm(Args _args)
{
//Initialization
DictTable dictTable;
DictTable dictTable1;
Form form;
FormBuildDesign design;
FormBuildDataSource formBuildDataSource;
FormBuildDataSource formBuildDataSource1;
FormBuildActionPaneControl actionPane;
FormBuildActionPaneTabControl actionPaneTab;
FormBuildButtonGroupControl buttonGroup1;
FormBuildButtonGroupControl buttonGroup2;
FormBuildCommandButtonControl CommandNew;
FormBuildCommandButtonControl CommandDelete;
FormBuildMenuButtonControl CustomerButton;
FormBuildFunctionButtonControl NewCustomerButton;
FormBuildFunctionButtonControl ForecastButton;
FormBuildGroupControl Grp;
FormBuildGridControl grid;
FormBuildGroupControl grpBody;
Args args;
FormRun formRun;
#task
//Adding DataSources
dictTable1 = new DictTable(tableNum(CustTable));
dictTable = new DictTable(tableNum(DirPartyTable));
form = new Form();
form.name(“Customer Overview”);
formBuildDataSource = form.addDataSource(dictTable.name());
formBuildDataSource.table(dictTable.id());
formBuildDataSource1 = form.addDataSource(dictTable1.name());
formBuildDataSource1.table(dictTable1.id());
//Building Form Design
design = form.addDesign(‘Design’);
design.caption(“Overview”);
design.style(FormStyle::SimpleList);
design.titleDatasource(formBuildDataSource.id());
//Adding Action Pane and Buttons
actionPane = design.addControl(
FormControlType::ActionPane, ‘ActionPane’);
actionPane.style(ActionPaneStyle::Strip);
actionPaneTab = actionPane.addControl(FormControlType::ActionPaneTab, ‘ActionPaneTab’);
buttonGroup1 = actionPaneTab.addControl(FormControlType::ButtonGroup, ‘NewDeleteGroup’);
buttonGroup2 = actionPaneTab.addControl(FormControlType::ButtonGroup, ‘ButtonGroup’);
CommandNew = buttonGroup1.addControl(FormControlType::CommandButton, ‘NewButton’);
CommandNew.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
CommandNew.normalImage(’11045′);
CommandNew.imageLocation(SysImageLocation::EmbeddedResource);
CommandNew.primary(NoYes::Yes);
CommandNew.command(#taskNew);
CommandDelete = buttonGroup1.addControl(FormControlType::CommandButton, ‘NewButton’);
CommandDelete.text(“Delete”);
CommandDelete.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
CommandDelete.normalImage(’10121′);
CommandDelete.imageLocation(SysImageLocation::EmbeddedResource);
CommandDelete.saveRecord(NoYes::Yes);
CommandDelete.primary(NoYes::Yes);
CommandDelete.command(#taskDeleteRecord);
CustomerButton = buttonGroup2.addControl(FormControlType::MenuButton, ‘CustomerquickCreate’);
CustomerButton.helpText(“Create New Customer”);
CustomerButton.text(“Customer”);
NewCustomerButton = CustomerButton.addControl(FormControlType::MenuFunctionButton, ‘CustomerquickCreate’);
NewCustomerButton.text(‘New’);
NewCustomerButton.saveRecord(NoYes::No);
NewCustomerButton.dataSource(formBuildDataSource.id());
NewCustomerButton.menuItemName(menuitemDisplayStr(CustomerquickCreate));
ForecastButton = buttonGroup2.addControl(FormControlType::MenuFunctionButton, ‘SalesForecast’);
ForecastButton.text(‘Forecast’);
ForecastButton.saveRecord(NoYes::No);
ForecastButton.menuItemName(menuitemDisplayStr(ForecastSalesGroup));
//Body
grpBody = design.addControl(FormControlType::Group, ‘Body’);
grpBody.heightMode(FormHeight::ColumnHeight);
grpBody.columnspace(0);
grpBody.style(GroupStyle::BorderlessGridContainer);
grid = grpBody.addControl(FormControlType::Grid, “Grid”);
grid.dataSource(formBuildDataSource.name());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(formBuildDataSource.id(), fieldNum(DirPartyTable,Name));
grid.addDataField(formBuildDataSource1.id(), fieldNum(CustTable,AccountNum));
grid.addDataField(formBuildDataSource.id(), fieldNum(DirPartyTable,LanguageId));
Grp = design.addControl(FormControlType::Group, ‘Group’);
ForecastButton = Grp.addControl(FormControlType::MenuFunctionButton, ‘SalesForecast’);
ForecastButton.text(‘Forecast’);
ForecastButton.menuItemName(menuitemDisplayStr(ForecastSalesGroup));
args = new Args();
args.object(form);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
}

{ 0 comments }

Create and post Vendor Invoice Journals from code as follow.

static void  createVendorInvoiceJournal(Args _args)
{
    LedgerJournalCheckPost  jourCheckPost;
    LedgerJournalTable      jourTable;

    AxLedgerJournalTable    header  = new AxLedgerJournalTable();
    AxLedgerJournalTrans    trans   = new AxLedgerJournalTrans();

    container               offsetDim;

    // The AP invoice journal name, could vary.
    LedgerJournalNameId     ledgerJournalNameId = "AP";

    // This is the entry against the Vendor account.
    // It will have to pre-exist for this script to work.
    // It is probably created the first time such an entry is
    // made on a journal line.
    DimensionAttributeValueCombination  davc;

    LedgerJournalACType         accType, offsetAccType;

    BankAccountTable            bankAccountTable;

    accType         = LedgerJournalACType::Vend;
    offsetAccType   = LedgerJournalACType::Ledger;

    header.parmJournalName(ledgerJournalNameId);
    header.parmJournalType(LedgerJournalType::VendInvoiceRegister);
    header.save();

    trans.parmAccountType(accType);
    trans.parmJournalNum(header.ledgerJournalTable().JournalNum);

    offsetDim   = ["52121-Disp", "52121", 2, "Site", "OK", "Department", "204"];    //First is Display value, followed by Main Account and then dimensions.

    trans.parmAccountType(LedgerJournalACType::Vend);
  
    // Note: This only works if the DimensionValueAttributeCombindation record
    // exists from before.
    select firstonly RecId from davc
        where davc.DisplayValue == "Vendor123"; //Vendor123 is the vendor account number.

    trans.parmLedgerDimension(davc.RecId);

    //There's a parm method for credit as well.
    trans.parmAmountCurDebit(99.15);
    trans.parmOffsetAccountType(offsetAccType);
    trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDim));

    trans.save();
  
    jourTable =  header.ledgerJournalTable();
  
    if (jourTable.RecId > 0)
    {
        jourCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(jourTable,
                                                                NoYes::Yes,
                                                                NoYes::Yes);
        // Post only if there is succesful validation.
        if (jourCheckPost.validate())
        {
            jourCheckPost.run();
        }
    }
}

{ 0 comments }

A year ago, I have to write a custom AIF service, where I have to extract All customer in Particular Legal Entity. For this purpose I have to create data Contract Classes and then these populate them and return from Service. The Customer Extraction on AIF will done on Customer Table level. But Address and Contact will be extracted from at DirPartyPostalAddressView and DirPartyContactInfoView
Code will be as follow.

List CustomerList;
    List addresses;
    List Contacts;
    CustomerDataContract objCust;
   
     CustAddressDataContract               objCustAC;
    CustContactDataContract               objCustCC;
  
    
    CustTable custtable;
    
    DirPartyPostalAddressView   addressView;
    DirPartyContactInfoView     contactView;
    DirPartyPrimaryContactInfoView partyprimaryView;
    int chunkSize = 10;

    while SELECT *
    FROM  custtable     
    {
        if(chunkSize >0)
        {
           objCust = new revCustomerDataContract();
           objCustAC = new revCustAddressDataContract();
           objCustCC = new revCustContactDataContract();


           objCust.parmAccountNum(custtable.AccountNum);
         objCust.parmCurrencyCode(custtable.Currency);
            //objCust.parmASNFlg(custtable.
            objCust.parmCustGroupId(custtable.CustGroup);
            objCust.parmOrganizationName(custtable.OrgId);
            objCust.parmInvoiceAccount(custtable.InvoiceAccount);
            objCust.parmCompanyChainId(custtable.CompanyChainId);
            objCust.parmPaymTermId (custtable.PaymTermId);
            objCust.parmPaymMode(custtable.PaymMode);
            objCust.parmCreditLimit(custtable.CreditMax);
            objCust.parmSiteId(custtable.InventSiteId);
            objCust.parmWarehouse(custtable.InventLocation);
            objCust.parmTaxGroup(custtable.TaxGroup);
            objCust.parmPriceGroup(custtable.PriceGroup);
            objCust.parmLineDisc(custtable.LineDisc);
            objCust.parmCountryId(custtable.PartyCountry);

           

              while SELECT *
              FROM  addressView where addressView.Party == custtable.Party
               {

                  objCustAC.parmStreet(addressView.Street);
                  objCustAC.parmCity(addressView.City);
                  objCustAC.parmState(addressView.state);
                  objCustAC.parmZip(addressView.ZipCode);
                  objCustAC.parmCountry(addressView.Address);
                  objCustAC.parmAccountNum(vendtable.AccountNum);

                  addresses.addEnd(objCustAC);

               }
              while SELECT *
              FROM  contactView where contactView.Party == custtable.Party
              {
                  objCustCC.parmAccountNum(custtable.AccountNum);
                  objCustCC.parmContactType(contactView.Type);
                  objCustCC.parmLocationName(contactView.LocationName);
                  objCustCC.parmLocator(contactView.Locator);
                  objCustCC.parmLocatorExtension(contactView.LocatorExtension);
                  objCustCC.parmPrimary(contactView.IsPrimary);


           
                 Contacts.addEnd(objCustCC);

              }
              objCust.parmAddresses(addresses);
              objCust.parmContacts(Contacts);
              vendorsList.addEnd(objCust);
       }
       chunkSize--;

   }



{ 0 comments }

AOS services can be start or stop through command line. Similar other services, One way to make .bat files and run them.

net stop “<"service name">”
net start “<"service name">“

So restarting the AOS service named AOS60$01 would be:

net stop AOS60$01
net start AOS60$01

You can determine the service name by going to Control Panel -> Administrative Tools -> Services and double clicking on the Service and looking in the field ‘Service name’.

Similarly you can restart the report server using:

net stop ReportServer
net start ReportServer

{ 0 comments }