I have a simple product configurator where, among other options, the user enters how many pieces they want of the part. Depending on this and some logic, I need to update the quote selling qty and the UOM on the quote line. I can accomplish this with the following code in the Document rules:
QuoteDtl.SellingExpectedQty = qty;
QuoteDtl.OrderQty = qty;
QuoteDtl.SellingExpectedUM = uom;
I assumed this would just work and it mostly does, except when it changes the UOM, the unit price of the “EA” UOM is pulled in regardless of what the UOM was changed to. And it seems like the “EA” unit price is then treated like the unit price for the UOM that was switched to, because when I switch the UOM back manually to “EA”, then the price divides to something smaller.
Even more strange, when I delete the line to start over, and manually add a line with the same part number again, then nothing updates anymore when I change the UOM or the quantity. I can even open a brand new quote with that part number and nothing updates there either. Only until I clear my browser cache, does everything work again.
I also tried doing a trace in the browser of what happens when I change the UOM in the quote manually, and I tried doing all of that in a Function:
Erp.Tablesets.QuoteTableset quoteTableset = new Erp.Tablesets.QuoteTableset();
Erp.Tablesets.QuoteDtlRow quoteDtl = new Erp.Tablesets.QuoteDtlRow();
Erp.Tablesets.QuoteDtlRow quoteDtlUpdate = new Erp.Tablesets.QuoteDtlRow();
this.CallService<Erp.Contracts.QuoteSvcContract>(quoteSvc => {
var quote = quoteSvc.GetByID(quoteNum);
var quoteDtlToCopy = quote.QuoteDtl.Where(qd => qd.QuoteLine == quoteLineNum).FirstOrDefault();
BufferCopy.Copy(quoteDtlToCopy, quoteDtl);
BufferCopy.Copy(quoteDtlToCopy, quoteDtlUpdate);
quoteDtlUpdate.SellingExpectedUM = newUOM;
quoteDtlUpdate.RowMod = "U";
quoteTableset.QuoteDtl.Add(quoteDtl);
quoteTableset.QuoteDtl.Add(quoteDtlUpdate);
quoteSvc.GetDtlUnitPriceInfo(false, false, ref quoteTableset);
quoteSvc.ChangeSellingExpQty(ref quoteTableset);
quoteSvc.Update(ref quoteTableset);
});
This works when called through rest, but does not work when called from the Document Rules.
What can I do to change the UOM in the quote from the Configurator?