1

Take any sales order with a line that has fields SalesLine.Name and SalesLine.ExternalItemId populated.

Then run following job trying to modify any field not related to the two above:

SalesLine sl = SalesLine::findInventTransId('US01-000025', true);
ttsBegin;
sl.CustomerLineNum = 100; //any other field will serve as well
sl.modifiedField(fieldNum(SalesLine, CustomerLineNum)); //causes the issue
sl.update();
ttsCommit;

When the job has completed, both Name and ExternalItemId will be reset.

The issue is caused by line this.axInventDim().isFieldSet(fieldNum(InventDim, ConfigId)) in \Classes\AxSalesLine\isCustExternalItemDescriptionFieldsSet, which always returns true.

As a result, methods AxSalesLine.setName and AxSalesLine.setExternalItemId populate respective fields with default values.

Any advice on the reason it has been coded in Microsoft this way, and the best way to fix this?

P.S. I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId that was introduced in R2 CU7

10p
  • 5,488
  • 22
  • 30
  • Could not reproduce the issue on R2 CU7. The field has been successfully updated. Are you sure there is no customizations on the way? – Maxim Lazarev May 12 '15 at 14:19
  • Probably in your scenario `InventDimCombination::findVariantId(salesLine.RetailVariantId)` didn't return a record, that's why you couldn't reproduce it. – 10p May 12 '15 at 15:27

2 Answers2

2

This is a base bug that was resolved 4/30/15 on KB3061573.

https://fix.lcs.dynamics.com/Issue/Resolved?kb=3061573&bugId=3612128&qc=83c15cd8881ece605195acc30e039142

I think the full method fix is close to what you have, but the hotfix may also adjust other methods. I hope this hotfix is satisfying knowing you're not crazy.

protected void setRetailVariantId()
{
    InventDimCombination    comb;
    InventDim inventDim;
    ;
    comb = InventDimCombination::findVariantId(salesLine.RetailVariantId);
    inventDim = this.axInventDim().inventDim();
    if(comb)
    {
        if (inventDim.InventSizeId != comb.inventDim().InventSizeId)
        {
            this.axInventDim().parmInventSizeId(comb.inventDim().InventSizeId);
        }
        if (inventDim.InventColorId != comb.inventDim().InventColorId)
        {
            this.axInventDim().parmInventColorId(comb.inventDim().InventColorId);
        }
        if (inventDim.InventStyleId != comb.inventDim().InventStyleId)
        {
            this.axInventDim().parmInventStyleId(comb.inventDim().InventStyleId);
        }
        if (inventDim.configId != comb.inventDim().configId)
        {
            this.axInventDim().parmConfigId(comb.inventDim().configId);
        }
    }
}
// </RETAIL>
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
  • 1
    Thanks a lot for looking into it! That's right, they used the same fix. The only reason I didn't add `if` conditions to the other 3 fields is that they were not directly related to the bug that was reported to me, and I decided not to touch whatever had been working fine. – 10p May 12 '15 at 22:33
  • This is a *great* find. Thanks Alex. In our case changing the order's Delivery terms was resetting the sales lines Price percentage discount. – ian_scho Jun 01 '16 at 10:53
  • @ian_scho - Glad I could help! – Alex Kwitny Jun 01 '16 at 15:29
0

As I mentioned in the postscript, I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId, which was introduced in R2 CU7.

As a workaround, I have added one line to the code, it resolved the issue:

if (this.axInventDim().parmConfigId() != comb.inventDim().configId) // added check
    this.axInventDim().parmConfigId(comb.inventDim().configId);

I'll wait some time for a better answer/fix. If none provided, I will accept this answer.

10p
  • 5,488
  • 22
  • 30