Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

QuoteAgent.GetProduct(int, string) doesn't set ProductId property.

Hi, 

I'm trying to use the QuoteAgent to retrieve a Product based on its ERPProductKey. I get a Product back, but it does not have the ProductId set, so when I save it a new one gets created.

Example code using CRMScript:

NSQuoteAgent quoteAgent;
NSProduct product = quoteAgent.GetProduct(1, "bubba");
printLine("ProductId: " + product.GetProductId().toString());
printLine("Name: " + product.GetName());
printLine("ERPProductKey: " + product.GetERPProductKey());
printLine("Code: " + product.GetCode());

The result looks like this, observe other fields are set, but not ProductId.

ProductId: 0
Name: Dustomatic 3000 vacuum cleaner
ERPProductKey: bubba
Code: ABC123

Bug?

RE: QuoteAgent.GetProduct(int, string) doesn't set ProductId property.

Hi Frode,

Its really up to the quoteconnector provider, and with the default SuperOffice connector, yes it would appear to be a bug. The source appears to only populate the ProductInfo.ERPProductKey with the ProductId if the ERPProductKey is null or empty. 

ERPProductKey = row.ERPProductKey.IsNullOrEmpty() ? row.ProductId.ToString() : row.ERPProductKey,

Why that class doesn't have a ProductId property is really odd.

Please submit a bug report to get enlisted in status and feedback.

Af: Tony Yates 10. aug 2018

RE: QuoteAgent.GetProduct(int, string) doesn't set ProductId property.

I believe, early on, we landet on the ERPProductKey, even for build-in products.
At least in the Win client, the productId is never used internally.
/conrad

Af: Conrad Weyns 10. aug 2018

RE: QuoteAgent.GetProduct(int, string) doesn't set ProductId property.

Conrad, the problem is that when I retrieve a product, but it doesn't contain a valid ProductId, it will create a NEW product when I make a change to it and save it.

My workaround for now is to do a lookup first in the crm7.Product table to see if I can get the ProductId based on an ErpKey, and if I find one then I load the product using GetProductByDbId instead.

Af: Frode Lillerud 10. aug 2018