Search code examples
axaptax++dynamics-ax-2012

Dynamic value in grid


How to write display method on data source - I've two joined table and I want to dynamically change values of grid column after control with Vendors are modified. My goal is to display different ExternalNumber after Vendors control is modified.

I've just written some code but it isn't working.

display str dispExternalItem()
{
    CustVendExternalItem ex;

    while select ExternalItemId from ex 
        where ex.ItemId == ReqTrans.ItemId
           && ex.CustVendRelation==CustVend.valueStr()
    {
        ExternalItemId.text(ex.ExternalItemId);
    }
    return ex.ExternalItemId;
}

Solution

  • For edit methods on datasources AX passes current buffer. Your edit method signature should look like:

    display ExternalItemId dispExternalItem(VendTable _vendTable)
    {
        CustVendExternalItem ex;
    
        select firstOnly ExternalItemId from ex 
            where ex.ItemId == ReqTrans.ItemId
                && ex.CustVendRelation == _vendTable.AccountNum
        ;
    
        return ex.ExternalItemId;
    }
    

    Also your display method shoud return EDT (ExternalItemId) instead of str. And bind to cursor value instead of control string property.