Category Archives: Dynamics AX 2012 R3

The best way to pass records to a class

This is the best method to pass the selected records from a Form to a Class

static void Main(Args args)
{
    MultiSelectionHelper    multiSelectionHelper;
    AssetTable              AssetTable;
    ;

    multiSelectionHelper = MultiSelectionHelper::createFromCaller(args.caller());
    assetTable  = multiSelectionHelper.getFirst();
    while (assetTable)
    {
        info(assetTable.AssetId);
        assetTable = multiSelectionHelper.getNext();
    }
}

MultiSelectionHelper class helps to iterate into selected records.
If you are using args object on your target class consider to use the method:

multiSelectionHelper.parmCacheRecords(true);

How to get SalesLine record from ReqTrans table using X++ AX 2012

Add these two methods to the ReqTrans table

public SalesLine getSalesLine(ReqTrans _reqTrans)
{
    ReqTrans        reqTrans_Settle,reqTrans_next;
    SalesLine       salesLine;
    ;
    reqTrans_Settle = _reqTrans.getSettleTrans();
    do
    {
        select reqTrans_next
            where reqTrans_next.RefId == reqTrans_Settle.RefId
               && reqTrans_next.Direction == InventDirection::Receipt;
        if (!reqTrans_next)
        {
            break;
        }
        reqTrans_Settle = reqTrans_next.getSettleTrans();
    }
    while(reqTrans_next);
 
    if(reqTrans_Settle.RefType == ReqRefType::Sales)
    {
        salesLine = SalesLine::findInventTransId(InventTransOrigin::find(reqTrans_Settle.InventTransOrigin).InventTransId);
    }
 
    return salesLine;
}
 
private ReqTrans getSettleTrans()
{
    ReqTrans    reqTrans_Settle;
    ReqTransCov reqTransCov;
    ;
 
    switch(this.Direction)
    {
        case InventDirection::Issue:
                select reqTransCov
                    where reqTransCov.IssueRecId == this.RecId;
 
                reqTrans_Settle = reqTrans::findRecId(reqTransCov.ReceiptRecId);
            break;
 
        case InventDirection::Receipt:
                select reqTransCov
                    where reqTransCov.ReceiptRecId == this.RecId;
 
                reqTrans_Settle = reqTrans::findRecId(reqTransCov.IssueRecId);
            break;
 
    }
 
    return reqTrans_Settle;
}

[AX 2012 R3] How to get avail quantity of a product by ItemId and get details by inventory dimensions (InventDimId)

 InventDimOnHand onHand;
 InventDimOnHandIterator iter;
 InventDimOnHandMember member;
 InventOnhand inventOnhand;
 ItemId itemId;
 InventDim inventDimCrit;
 InventDimParm inventDimParmCrit, inventDimParmOnHandLevel;
 InventDim inventDim;
 InventDimOnHandLevel level;
 ;

 itemId = '123456';

 // Known dimensions
 inventDimCrit.wMSLocationId = 'location01';
 inventDimCrit = InventDim::findOrCreate(inventDimCrit);

 // Determine which of the known dimensions to use
 inventDimParmCrit.WMSLocationIdFlag = true;

 level = InventDimOnHandLevel::DimParm;

 // Determines the level of detail returned
 inventDimParmOnHandLevel.ItemIdFlag = true;
 inventDimParmOnHandLevel.InventLocationIdFlag = true;
 inventDimParmOnHandLevel.WMSLocationIdFlag = true;
 inventDimParmOnHandLevel.InventBatchIdFlag = true;

 onHand = InventDimOnHand::newPhysicalArrived(itemId, inventDimCrit, InventDimParmCrit, level, inventDimParmOnHandLevel);

 iter = onHand.onHandIterator();
 while (iter.more())
 {
 member = iter.value();
 inventDim = InventDim::find(member.parmInventDimId());
 inventDimParmOnHand.initFromInventDim(inventDim);
 inventOnHand = InventOnhand::newParameters(itemId, inventDim,inventDimParmOnHand);
 info(con2str([member.parmItemId(), inventDim.inventLocationId, inventDim.inventBatchId, inventDim.LicensePlateId, inventDim.inventSerialId, member.parmInventQty(), inventOnHand.availPhysical()]));

 iter.next();
 }

 info('Done'); 

[AX 2012 R3] How to get product color description

We want to display the description of a dimension (in this case the colour) of a product

We just need the ItemId and InventColorId

productAx

static void GetColorDescription(Args _args)
{
 ItemId ItemId = "123456789"; //Change with your ItemId
 EcoResProductMasterColor EcoResProductMasterColor;
 EcoResProductMasterDimensionValue EcoResProductMasterDimensionValue;
 EcoResColor EcoResColor;
 EcoResProductMaster EcoResProductMaster;
 EcoResProductMasterDimValueTranslation EcoResProductMasterDimValueTranslation;
 
 EcoResColorName EcoResColorName = InventDim::find("InventDimId").InventColorId; 

 select * from EcoResProductMasterDimValueTranslation
 join RecId from EcoResProductMasterDimensionValue
 where EcoResProductMasterDimValueTranslation.ProductMasterDimensionValue
 == EcoResProductMasterDimensionValue.RecId
 join RecId from EcoResProductMasterColor
 where EcoResProductMasterDimensionValue.RecId == EcoResProductMasterColor.RecId
 join RecId from EcoResColor
 where EcoResColor.RecId == EcoResProductMasterColor.Color
 && EcoResColor.Name == EcoResColorName
 join RecId from EcoResProductMaster
 where EcoResProductMasterColor.ColorProductMaster == EcoResProductMaster.RecId
 && EcoResProductMaster.DisplayProductNumber == ItemId;

 info(EcoResProductMasterDimValueTranslation.Name);
}

In case you don’t have any translaction
ax2012r3_product_with_no_translation
the object EcoResProductMasterDimValueTranslation.Name will be empty, so you can retrive the Deault value using this code:

static void GetColorDescription(Args _args)
{
 ItemId ItemId = "123456789"; //Change with your ItemId
 EcoResProductMasterColor EcoResProductMasterColor;
 EcoResProductMasterDimensionValue EcoResProductMasterDimensionValue;
 EcoResColor EcoResColor;
 EcoResProductMaster EcoResProductMaster;
 EcoResProductMasterDimValueTranslation EcoResProductMasterDimValueTranslation;
 
 EcoResColorName EcoResColorName = InventDim::find("InventDimId").InventColorId; 

 select * from EcoResProductMasterDimValueTranslation
 join RecId from EcoResProductMasterDimensionValue
 where EcoResProductMasterDimValueTranslation.ProductMasterDimensionValue
 == EcoResProductMasterDimensionValue.RecId
 join RecId from EcoResProductMasterColor
 where EcoResProductMasterDimensionValue.RecId == EcoResProductMasterColor.RecId
 join RecId from EcoResColor
 where EcoResColor.RecId == EcoResProductMasterColor.Color
 && EcoResColor.Name == EcoResColorName
 join RecId from EcoResProductMaster
 where EcoResProductMasterColor.ColorProductMaster == EcoResProductMaster.RecId
 && EcoResProductMaster.DisplayProductNumber == ItemId;

if(EcoResProductMasterDimValueTranslation.Name)
{
info(EcoResProductMasterDimValueTranslation.Name);
}
else
{
EcoResProductMasterDimValueTranslation = EcoResProductMasterDimValueTranslation::getNameOrDefaultName(EcoResProductMasterDimensionValueId, SystemParameters::getSystemLanguageId()); info(EcoResProductMasterDimValueTranslation.Name);
info(EcoResProductMasterDimValueTranslation.Name);
}

Microsoft Dynamics AX 2012 R3: a preview

It’s all about Amazing Customer Experiences
Over the past few years Microsoft Dynamics AX has evolved to be the default enterprise resource planning (ERP) choice for many organizations. Our focus on innovation and business value to our customers has grown our Microsoft Dynamics AX community to more than 20,000 customers across more than 36 countries. That makes us happy.
Now, we’re so excited to be unveiling Microsoft Dynamics AX 2012 R3, planned for release in April 2014. And you know why? Because we know it will help you to provide Amazing Customer Experiences! With new features and tools available through this release, you’ll be able to engage with customers on their terms, run agile operations to exceed your customers’ needs, and expand your business to better serve your customers.
Engage with customers on their terms
Customers are increasingly demanding a seamless shopping experience across channels and an unprecedented degree of interaction with – or ‘ownership’ of – consumer brands. Mobile experiences delivered through Microsoft Dynamics AX 2012 R3 provide differentiating customer-facing experiences that help you:
  • Engage anytime, anywhere. Online, in store or on-the-go, customers want business on their own terms. With the next release, you can get tools to create seamless omni-channel engagements, with the ability to handle multiple languages and storefronts.
  • Offer deeply engaging, rich experiences. We’re closing the gap between the systems that capture the data and the people who can use it to benefit customers. You’ll be able to provide more meaningful services and advice to your customers in a way that makes sense for them.
  • Build profitable customer relationships. New social channels integration and ecommerce new features in Microsoft Dynamics AX 2012 R3 let teams work together to serve customers in new ways, including support for customer-specific pricing, wish lists, and unassisted sales. Get support for loyalty programs across legal-entities and tiering of customers as well as enhanced gift card functionality. Even incorporate Facebook and Twitter into campaigns right out of the box.
Satisfy changing customer needs
We know you want to respond to fast-changing business conditions and move quickly to capitalize on new opportunities. Look to Microsoft Dynamics AX 2012 R3 to help you streamline your business and make customers happy:
  • Offer choices. New and integrated Warehouse and Transportation Management capabilities helps you provide your customers with the fulfillment choices they want. You can even quickly act on their changing requirements with a few clicks of a button—and still keep logistics and transportation costs low.
  • Respond to continuously shifting customer requirements. Timely, end-to-end visibility into supply chain operations helps you balance inventory and operating expenses. In addition, we now provide support for basic SKU-level demand forecasting based on historic data, using a combination of Microsoft SQL Server and Microsoft Excel to view, visualize, and edit the forecast data.
  • Share highly-responsive, timely delivery insights with customers. With the integrated warehousing and transportation capabilities you have insight into your global supply chain with a few clicks, and can share this insight with your customers since they value information about their order status as much as receiving the order.
Serve your customers better and expand your business
Grow into new markets and new customer segments. Blend in new acquisitions and new lines of business without sacrificing enterprise-wide visibility and process controls. Microsoft Dynamics AX 2012 R3 can help reach new customers in new ways:
  • Deliver solutions to new geographies. Single-instance solutions help deploy organizational best practices to new geographies quickly and easily—without starting from scratch. The planned Master Data Management capabilities also support decentralized global installations. Manage Microsoft Dynamics AX projects from pre-sales to implementation and operations Lifecycle Services, a cloud-based framework that makes it easier to grow.
  • Innovate products and services. With Microsoft Dynamics AX 2012 R3, you and your employees have the insight and flexibility to drive innovation that improves business operations and the way they serve customers—empowering you to give customers what they want, when they want it.