Happy Business Starts Here

Highlighted
Valued Scholar

Validation after editing products on a saved quote

Hi,

 

We need to add some validation rules into our quoting process, and after a few experiments with the product selector component plugins, we've resorted to adding an extra step at the end of the quote wizard to validate that a quote has been configured correctly.

 

We would have ideally liked to have used the component plugins to validate the configuration before or on saving, but we unfortuantly hit some limitations around custom fields and our slightly complicated discount validation rules which made it impossible. 

 

The extra step seems to do what we need, but the issue I'm facing now is with editing the quote after saving. 

 

If you need to make changes to the quote products, you hit the `Edit Products` button on the quote layout. This launches `zqu__EditQuoteProducts` directly and not via the quote wizard and therefore our validation step does not get called when the quote is saved.

 

This means you can take a perfectly valid quote, then edit the products in such a way that makes the quote invalid and then save the quote without error.

 

Does anyone know if there is a way to set up a button to open the quote wizard at a particular step?

 

Thanks,

 

Chris

7 REPLIES 7
Highlighted
Guru

Re: Validation after editing products on a saved quote

@chrisauckland Are you using Salesforce native validation rules or one of the Zuora plugins? Also what version of Quotes/CPQ are you running.

 

Reason I ask, is this sounds like a perfect application of the Zuora Rules Engine. This allows you to verify conditions during quote product entry and either alert the user if a mistake is made, or automatically make corrections (i.e. add / remove / update products on the quote). Finally if you need to get really advanced, you can add custom Apex to let your rule do almost anything.

Highlighted
Valued Scholar

Re: Validation after editing products on a saved quote

Hi @feisley thank you very much for the reply.

 

You're correct that this sounds exactly like the sort of thing we should be doing with a `Zuora Rules Engine Plugin`. We tried that first, but we had some problems. The main problem is that we have a `zqu__QuoteRatePlanCharge__c` custom field that needs to be populated and syncrhonized with all the other charges within the same quote rate plan. We would have wanted to have the custom field on the quote rate plan, but the product selector doesn't offer the nice UI for editing a field on a quote rate plan, so we have ended up having the field on each of the charges and using a javascript Product Selector Plugin to synchronize the values. The issue we have here is that there is a race condition where the rules engine plugin runs before the javascript plugin completes so the rules engine plugin returns false positives. I'm not sure how we can get around this. 

 

We have also tried using a `ISaveRatePlanPlugin` but the issue we found there was that the product selector seems to treat adding a new product to a quote as a save action, and since the custom field isn't availible on the add product page, the validation tells you off about not setting the field before you've had any opportunity to set it.

 

Our most successful workaround was to add a validation page to the quote wizard, but this validation can then easily be bypassed by editing the quote after saving, or in the summary page before you 'send to zuora'. We've heard from their support team that customer have needed to add some final validation to the 'send to zuora' button, so it sounds like this is an issue others have found. 

Highlighted
Zuora Staff

Re: Validation after editing products on a saved quote

Hi Chris,

 

To avoid the race condition of the JS Plugin and the Rules Engine firing, have you tried disabling the "Enable Real Time Rule Calculation" setting in Zuora Config -> Advanced Quoting Configuration Settings? This will prevent the rules engine from firing on changes, and will instead only fire on click of "Calculate", "Save" or "Submit". This should avoid the race condition as the JS plugin will be completed real-time on field updates, while the rules will only run on page save.

 

Alternatively, you can create a custom VF page and embed the product selector component. This allows you to leverage the OOTB functionality of the product selector, but also to provide your own "next page" reference upon save. You can embed the "EditQuoteProduct" component on your VF page with the following code

 

<zqu:EditQuoteProduct editQuoteProductOptions="{!editProductOptions}" />

 

 

 

This component takes in an attribute "zqu.EditQuoteProductOptions". This takes in an attribute "zqu.SelectProductComponentOptions" where you can specify a "saveUrl" and "savePageParams" to redirect with upon existing the product selector.

 

//Options for "Edit Charges" view
zqu.SelectProductComponentOptions selectOptions = new zqu.SelectProductComponentOptions();
selectOptions.quoteType = 'quote type from url';
selectOptions.quoteId = 'quote id from url';
selectOptions.saveUrl = Page.YourCustomPage.getUrl();
selectOptions.savePageParams = nextParams; //Map<String,String> of URL params

//Options for "Guided Selling" view
zqu.ProductBundleGuidedSellingOptions guidedOptions = new zqu.ProductBundleGuidedSellingOptions();
guidedOptions.quoteType = 'quote type from url';;
guidedOptions.quoteId = 'quote id from url';

zqu.EditQuoteProductOptions editProductOptions= new zqu.EditQuoteProductOptions();
editProductOptions.productSelectorOptions = selectOptions;
editProductOptions.guidedSellingOptions = guidedOptions;
editProductOptions.initialComponentMode = zqu.EditQuoteProductOptions.PRODUCT_SELECTOR_MODE;

 

 

Thanks,

Mikey

Highlighted
Valued Scholar

Re: Validation after editing products on a saved quote

Hi Mikey,

 

Disabling the "Enable Real Time Rule Calculation" option has solved a lot of the problems we were having using the "QuoteRulesEnginePlugin", so thanks for the suggestion.

 

The issue I'm hitting now is that the rules run as soon as the page loads, and since the custom field that requires setting is blank (or set to 'please select') then the error is triggered. Is there any way to supress the validation when the page loads and only run through the validation on 'calculate', 'save' or 'submit'? The business rules we have for choosing the appropriate value for this field is going to be very tricky to do programmatically, so we require the user to select the right option when configuring the quote. i.e. the value needs to start off being an invalid value, to force the user to set it, but it would be nice if the user wasn't informed of the error before they get a chance to set it. 

 

Thanks,

 

Chris 

Highlighted
Zuora Staff

Re: Validation after editing products on a saved quote

Hi Chris,

 

Unfortunately, there is no way to determine the context the QuoteRulesEnginePlugin is being triggered from (load vs save/calculate). 

 

 

Thanks,

Mikey

Valued Scholar

Re: Validation after editing products on a saved quote

Hi Mikey,

 

Thanks for confirming.

 

I've now tried to move the validation code over to the `ISaveRatePlanPlugin`, which seems to be almost there, but I think I might be misunderstanding how to use it properly. 

 

The example code only shows throwing an exception when a validation error occurs. This is fine to point out the error when clicking 'save', but it doesn't stop you from 'submitting' the quote. i.e when you you click 'submit' the exception will pop up, but it will still save the quote and progress to the next page. 

 

It would be nice if we could return the user to the product selector if an exception is thrown by the 'ISaveRatePlanPlugin`. Do you know if this is possible?

Highlighted
Valued Scholar

Re: Validation after editing products on a saved quote

Hi Mikey,

 

Also, I presume there isn't a way to set the rules engine to only trigger on save/calculate but not on load?