Search code examples
axaptadynamics-ax-2009

In SalesTable form, how to protect salesLine dimensions when items are already picked up?


In our Dynamics Ax 2009 configuration, we would like to avoid stock dimensions to be changed once the items are picked up or delivered. Sometimes users change the facial stock dimensions (warehouse, location) on the sales lines while transactions have already been registered.

I'm not aware of a way to protect this by a change in Stock or Sales parameters.

I try to solve this, with a change in active() method in the Salesline datasource of the SalesTable form, which calls a specific method :

if (InventDim_Ds.allowEdit())
{
    if (SalesLine.pickedInTotalSalesUnit() != 0 || SalesLine.DeliveredInTotal() != 0)
    {
        InventDim_Ds.allowEdit(false);
    }
}

But it doesn't work, or works too well : now it is impossible to change the stock dimensions, even if nothing has been picked or delivered.

I assume this has to do with the link between sales lines and dimensions, but I don't know how to fix my code.


Solution

  • On first glance, it looks like your issue is with:

    if (InventDim_Ds.allowEdit())

    As it doesn't allow changes between lines. If one line is picked, it will disable the InventDim_Ds, then when you move to the next SalesLine triggering the active() method, it will see that it's disabled and not enter the if statement.

    Try this:

    InventDim_ds.allowEdit(!salesLine.pickedInTotalSalesUnit() && !salesLine.deliveredInTotal());