Search code examples
microsoft-dynamicsaxapta

How to convert display methods into fields in ax2012


Dear great minds i want to convert this display method into field for PurchLine grid in ax2012 particularly i am facing issue to set condition where to set this condition ?

[SysClientCacheDataMethodAttribute(true)]
display PurchLineShowItemName itemName()
{
    PurchLineShowItemName purchLineShowItemName;

    if (this.ItemId)
    {
        purchLineShowItemName = this.inventTable().itemName(this.inventDim());
    }
    else
    {
        purchLineShowItemName = this.Name;
    }

    return purchLineShowItemName;
}

Solution

  • I would suggest you to create a view that will have a purchline as a datasource and 2 columns e.g.: PurchLineRecId and ItemName and the second column will be a computed field. Then you can implement this logic in a view method.

    Walkthrough: Add a Computed Column to a View

    After that you can add this view as form datasourse and join PurchLine by RecId.