Changing address format in AX 2012


For USA country region, the default address will look like this:

Company Name
Street Name
City,StateZIPCode
Country

In order to correct this formatting and provide space between city and state and zip code.

Navigate to:

->/Organization administration/Setup/Addresses->Address Setup
In Country/Region tab, check the Address Format number that’s associated with the country related to your legal entity.
Country-Address
 
Change Address Format 0008:
Append a space in the Seperator column for “City
Append a space in the Seperator column for “State or province
Click “Save” in the “Configure address component” tab
Click “Update address” and run the batch.
Address format
All addresses are stored in table LogisticsPostalAddress.
All addresses are fetched from view LogisticsPostalAddressView.

Update Production Order Status to Started via code X++ in AX 2012

Update Production Order Status to Started via code X++ in AX 2012

Scenario: We have a batch job that posts all unposted picking lists that were imported from an external file.
Problem: Picking list can only be posted for those production orders that are in Started state.
Solution: Before posting, set the production order status to started.

CODE:

static void setProdStatusStarted(Args _args)
{
    ProdUpdStartUp      prodUpdStartUp;
    ProdParmStartUp     prodParmStartUp;
    ProdParametersDim   prodParametersDim;
    ProdTable           prodTable;
    
    ProdId              prodId = "PROD-0001";
    
    prodTable = ProdTable::find(prodId);
    
    ttsBegin;
    prodParmStartUp.initValue();
    prodParmStartUp.initParmDefault();

    prodParametersDim = ProdParametersDim::find(prodTable.InventDimId);

    prodParmStartUp.initFromProdParametersDim(prodParametersDim);
    prodParmStartUp.ProdId = prodTable.ProdId;
    prodParmStartUp.PostNowBOM = NoYes::No;

    prodParmStartUp.insert();
    ttsCommit;

    prodUpdStartUp = ProdUpdStartUp::construct();
    prodUpdStartUp.parmParmBuffer(prodParmStartUp);
    prodUpdStartUp.run();
}

Copying Fixed Assets in Dynamics AX 2012 using X++ code


In this post, we will take a look how we can copy fixed assets in Microsoft Dynamics AX 2012 programmatically using X++ code.

You need a job to execute the code.

In the AOT (Application Object Server), right-click on the Jobs node and click New Job.

Write the following code:

/// <summary>
///     This AOT Job copies a specified fixed asset  a certain number of times within the specified company.
///         Param "numberOfCopies" tells how many times the fixed asset will be copied.
///         Param "assetId" tells what fixed asset is to be copied.
/// </summary>
static void copyAsset()
{
    int counter;
    int numberOfCopies = 10; // Specify how many copies do you want

    AssetTable              assetTable;
    AssetCopy               assetCopy;
    AssetId                 assetId = 'BUIL-001'; // Specify the Fixed Asset Id
    SysOperationProgress    progress = new SysOperationProgress();

    #AviFiles

    assetTable = AssetTable::find(assetId);

    if(assetTable)
    {
        counter = numberOfCopies;

        try
        {
            progress.hide();
            progress.setCaption(strFmt('Copying Fixed Asset "%1"', assetId));
            progress.setAnimation(#AviUpdate);
            progress.setTotal(numberOfCopies);

            while(counter>0)
            {
                assetCopy = new AssetCopy(assetTable);
                assetCopy.run();

                counter--;
                progress.setText(strfmt('%1 copies of fixed asset "%2" has been created.', numberOfCopies-counter, assetId));
                progress.setCount(numberOfCopies-counter, 1);
            }
        }
        catch(Exception::Error)
        {
            error('Operation failed to completion.');
        }

        if((numberOfCopies-counter)>0)
        {
            info(strFmt('Fixed Asset "%1" has been copied "%2" times sucessfully.', assetId, numberOfCopies-counter));
        }
        else
        {
            error(strFmt('No copies wrere created for fixed asset "%1".', assetId));
        }
    }
    else
    {
        error(strFmt('Fixed Asset "%1" cannot be found.', assetId));
    }
}

Run the job. Assets Copied.

Cost Control in Project Management & Accounting Module


In this article, we will discuss the Cost Control feature in Project Management & Accounting Module in Dynamics AX 2012.

Go to Common -> Projects -> All Projects and create a New Project

01__Create.a.New.Project

On the Action Pane, click Item Forecast in Forecast Tab.

02__Click.Item.Forecast

Create a new Item Forecast.

03__Create.Item.Forecast

Click New and create a New Item Forecast. Select an Item and forecast quantity.

Make sure, what-ever item you select, it has its cost price setup in the inventory, otherwise it will not take the manually entered cost price of the item during creation of item forecast. This can be a major flaw in the project management process where the user would look for committed cost for the said item forecast and he will find a zero committed cost due to no cost being registered with the item. Sales Price will however reflect in this whole iteration.

Once the Item Forecast is setup. Click the item forecast record and Click Copy at Action Pane on the Item Forecast form.

04__Copy.Item.Forecast

Clicking Copy, makes the forecast and Item Requirement.

You can see this Item Requirement when you click Item Requirements in the Action Pane at Projects -> Common -> All Projects.

05__See.Item.Requirements

06__Item.Requirements.List.Page

Now, at this point in time, we have committed a cost for our project in terms of recently created item requirement for 1000 items for Item#1171.

We can track this committed cost when we click Committed Cost in Cost Tab on Cost Action Tab at Projects -> Common -> All Projects list page.

07__View.Committed.Cost

08__Comitted.Costs