CRM Quote Connector - Detecting change of Product Code / Adding a new product

Hi,

I am writing a connector to lookup product prices from an ERP when the product code changes (either for a new line or and existing one) and also when the quanity/discount changes on an exisitng line.

I have been able to implement the change of quantity/discount fine, but I am unsure of the behaviour when a product code is changed/added.

The event I thought would fire was: ProductInfo GetProduct(QuoteAlternativeContextInfo context, string erpProductKey) but this doesn't ever seem to fire when the product code is changed.

The only event that does fire when I change or add a new product code is: QuoteLineInfo[] GetQuoteLinesFromProduct(QuoteAlternativeContextInfo context, string erpProductKey) but this is called 4 times whenever I change a product code?

Please can you advise how I should properly detect the change of product code (for a new line or an existing one)?

Cheers

Rich

 

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

This is seen from the Win client p.o.v....
The connector is never told that it is working on behalf of some New or Existing QuoteLine.

From the QuoteLine dialog:

- Search for a product => ERPProductKey
- QuoteAgent->CreateQuoteLine( QuoteAlternativeID, ERPProductKey )
- Connector -> GetQuoteLinesFromProduct (as you discovered)
This returns a QuoteLine array but only the first one is ever used.

If this was on behalf of an exisiting QuoteLine, internal data is merely updated.

In WIn, Creating a new quoteline or editing an existing quoteline by changing the product key will call the connector's GetQuoteLinesFromProduct once.

As I see it, in order to catch a change of product key, you will need to dig into the service layer event system.
The connector cannot know.

Conrad

 

Von: Conrad Weyns 10. Jan 2020

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

Many thanks Conrad,

I need this to work in both Windows and Web, would your suggestion still be possible?

Also, Why does this function fire once in Windows but 4 times in web?

Cheers

Rich

 

Von: Rich Hacker 13. Jan 2020

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

Hi Rich,
Yes, the Quote system in Win is actually using the Quote service layer in Nertserver. So the code you write for the service layer events should work in both Web and Win.
But you will have to install it on every single Win client since we run netserver in-process. There is no "server" involved.
I have never played with that so I have no idea how to do that. I suspect you need to doctor the SuperOffice.config xml file.

As far as why Web should call your connector 4 times, it's not for me to say.
In my experience, interactions in loosely bound GUI code is prone to noise. It may need many iterations to get it right. The Win client is no exception!

Regards,
/conrad

NB: WIn still has its QuoteLine script & COM event system available.
But I can't recomment using it for Quote intergrations.

Here is what the script event viewer is showing me when I change the erpProductKey of a quoteLine:

29: 20:32:31:473 OnUsageStatAdded (1) [VT_BSTR] win.ViewShown.MainWindow.QuoteDialogModal.QuoteDialogAlternativesViewBase21.QuoteLineDialog.QuoteLineMainView
30: 20:32:51:411 OnQuoteLineFieldsChanged (1) [VT_BSTR] PopulateFromERPProductKey, [VT_UI4]72, [VT_BSTR] BINARYDATA,BINARYDATA,CODE,EARNINGAMOUNT,EARNINGPERCENT,ERPPRODUCTKEY,SUBSCRIPTIONSTART,NAME,PRICEUNIT,PRODUCTCATEGORYKEY,PRODUCTFAMILYKEY,PRODUCTTYPEKEY,QUANTITYUNIT,SUPPLIER,SUPPLIERCODE,TOTALPRICE,UNITCOST,UNITLISTPRICE,UNITMINIMUMPRICE, [VT_INT]32767, [VT_INT]52489, [VT_INT]52489, [VT_INT]32523, [VT_INT]32549, [VT_INT]32548, [VT_INT]32515, [VT_INT]32529, [VT_INT]32521, [VT_INT]32525, [VT_INT]32532, [VT_INT]32533, [VT_INT]32534, [VT_INT]32524, [VT_INT]32535, [VT_INT]32536, [VT_INT]32550, [VT_INT]32539, [VT_INT]32541, [VT_INT]32540
31: 20:33:34:446 OnUsageStatAdded (1) [VT_BSTR] win.SaveClicked.MainWindow.QuoteDialogModal.QuoteDialogAlternativesViewBase21.QuoteLineDialog
32: 20:33:34:457 OnQuoteLineBeforeSave (1) [VT_I4] 72
33: 20:33:34:533 OnQuoteLineFieldsChanged (1) [VT_BSTR] SaveModel, [VT_UI4]72, [VT_BSTR] UPDATED, [VT_INT]32560
34: 20:33:34:559 OnQuoteLineSaved (1) [VT_I4] 72
35: 20:33:34:574 OnFilterRestrictionsFor_quoteline_salequotelinearchive (0) [VT_BSTR] quoteline, [VT_BSTR] salequotelinearchive, [VT_BSTR] superoffice:sale.quotearchive?db_id=1010000014&quoteline_id=72&sale_id=92, [VT_BSTR] active=True&name=quoteAlternativeId&operator=equals&numvalues=1&value=21|active=True&name=quoteLineId&operator=equals&numvalues=1&value=72
36: 20:33:35:522 OnQuoteAlternativeFieldsChanged (1) [VT_BSTR] Recalculate, [VT_UI4]21, [VT_BSTR] EARNINGAMOUNT,EARNINGPERCENT,TOTALPRICE,VAT, [VT_INT]12047, [VT_INT]12046, [VT_INT]12048, [VT_INT]12045
37: 20:33:35:632 OnQuoteAlternativeBeforeSave (1) [VT_I4] 21
38: 20:33:35:645 OnQuoteAlternativeFieldsChanged (1) [VT_BSTR] SaveModel, [VT_UI4]21, [VT_BSTR] UPDATED, [VT_INT]12056
39: 20:33:35:655 OnQuoteAlternativeSaved (1) [VT_I4] 21
40: 20:33:35:665 OnViewPreHide (1) [VT_I4] 73064, [VT_BSTR] MainWindow.QuoteDialogModal.QuoteDialogAlternativesViewBase21.QuoteLineDialog.QuoteLineDialogDetailsView

 

Von: Conrad Weyns 13. Jan 2020

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

Conrad,

Thanks again foir this.

We don't really need to detect if it is a change to an existing or new line. We only need to detect the value of the product code when the user selects a product from a search and clicks enter.

Without delving into anything else but the Quote Connector, can we use this approach or is there any other way of detecting this event?

The reason we need to detect this, is to a perform a stock/price lookup when the product is selected.

Cheers


Rich

 

 

Von: Rich Hacker 14. Jan 2020

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

Ok, I think I understand now.
Your connector should work in Win too. But it needs to be registered in the <DynamicLoad> section of every user's SuperOffice.config file. And the dll copied to the folder where SoCrm.exe lives..

Conrad

NB: I forgot this:

Have a look at SoAdmin/Options/SOLoader.

 

Von: Conrad Weyns 15. Jan 2020

RE: CRM Quote Connector - Detecting change of Product Code / Adding a new product

Conrad,

Many thanks for all your input on this, much appreciated!

Cheers

Rich

 

Von: Rich Hacker 15. Jan 2020