
I recently have run into a really frustrating behavior of the Currency control in the Infor CRM web client. Running in an 8.3.08 system, the following issues exist out of the box:
If you bring up the edit screen for an Opportunity Product, you can see this issue with the Currency control.
By default this screen has the Currency control for the adjusted price set up to 4 decimals. Why? Who knows, but it does. Lets try out some scenarios:
Type in “4” into the Adjusted Price(Base) field.
This works successfully and calculates the Discount and the Extended Price just fine:
Type in “4.0” into the Adjusted Price(Base) field. Tab out of it.
This works successfully and calculates the Discount and the Extended Price just fine:
Type in “4.0” into the Adjusted Price(Base) field. Click out of it.
This throws a server error on the change event of the field:
This is coming from a standard rule in the compiled BusinessRule assembly UpdateDiscountFromCalculatedSales. In this code it calls another supposrting method called GetDiscountPercentFromBaseAndDiscountedPrices with this lovely line of code:
opportunityProduct.Discount = new double?(GetDiscountPercentFromBaseAndDiscountedPrices(opportunityProduct.Price.Value, opportunityProduct.CalculatedPrice.Value));
The problem is the the CalculatedPrice field at this point is null and does not have a value. The reason?
Well if you close the error popup and look at the Currency control, a client side validator has stated 4.1 is not a valid number.
Note that the currency control has added the remaining 3 digits to make the number you entered show “4.0000” instead of “4.0”. Nice coding.
This continues on where clicking out of the field causes an error until you actually type in the correct number of decimals, like “4.0000”. Tabbing out of the field doesn’t throw the error regardless of the number of decimals.
How do we fix this? Well you could override the Currency controls by adding your own module and loading it, just like you do for Activity customizations. Lets do it a bit different and modify the core.master file. This is the main master file that all the other masters inherit from, so adding javascript code here will essentially wire it up everywhere.
Open the core.master file. At the very end before the closing tags for body and html, you can add this code:
<script type="text/javascript"> require(['dojo/aspect', 'dojo/_base/lang', 'Sage/UI/Controls/CurrencyTextBox'], function (aspect, lang, CurrencyTextBox) { // force control to validate on blur aspect.after(Sage.UI.Controls.CurrencyTextBox.prototype, 'onBlur', function () { this.validate(); }); // modify onChanged to only trigger postback if control has passed validation lang.extend(CurrencyTextBox, { onChanged: function (e) { if (this.shouldPublishMarkDirty) { dojo.publish('Sage/events/markDirty'); } if (this.autoPostBack) { if (Sys) { if (this.isValid()) { // make sure is valid before triggering postback Sys.WebForms.PageRequestManager.getInstance()._doPostBack(this.id, null); } else { this.reset(); } } } } }); }); </script>
This code adds code after the CurrencyControl dojo widget’s onBlur function, to call the validate function. This will make the validation occur both when tabbing out and when clicking out of the control.
The other code is extending the CurrencyControl widget using extend to override the default onChanged function. The reason for this code is because in the standard code, if the user input fails validation it still fires the postback despite there not being a valid value. This will cause problems if you have a postback on the change action of a field expecting a value.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!