1
votes

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

2
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
Probably in your scenario InventDimCombination::findVariantId(salesLine.RetailVariantId) didn't return a record, that's why you couldn't reproduce it. - 10p

2 Answers

2
votes

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>
0
votes

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.