Infor CRM (Formerly Saleslogix) Setting Currency Control Value Client Side

I recently had a client, running Infor CRM 8.1.5, that needed to set a currency control client side in the web client.  The Infor controls are extremely light *cough non-existent cough* in client side support.  Figuring this out took way too much time.  The currency control is rendered into the DOM as an HTML Span element.  There are several child elements in that and they don’t all contain an ID with which to easily access them.  jQuery to the rescue!

Here is what we had to do. In my case the control is was trying to set was named curActualAmount.  So the highlighted bits would need to change.  The parts to specifically set the currency value is in the function “setMe”.   The important thing to note is you need to set both the CurrencyTextBox and InputCurrency element’s values to get the new number to both display on screen and get saved.  The other stuff included below are supporting functions used by the “setMe” function.

function setMe()
{
   var tot = 1200;
   $(“input[name=’ctl00$” + curActualAmount.ClientID.Replace(“_”, “$”) + “$InputCurrency’]”, $(‘#” + curActualAmount.ClientID + “‘)).text(tot).val(tot).attr(‘aria-valuenow’, tot);
   $(‘#” + curActualAmount.ClientID + “_InputCurrency_CurrencyTextBox’).text(tot).val(‘$’ + tot.formatMoney(2,’.’,’,’)).attr(‘aria-valuenow’, tot);
}
Number.prototype.formatMoney = function(c, d, t){
   var n = this,
   c = isNaN(c = Math.abs(c)) ? 2 : c,
   d = d == undefined ? ‘.’ : d,
   t = t == undefined ? ‘,’ : t,
   s = n < 0 ? ‘-‘ : ”,
   i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + ”,
   j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : ”) + i.substr(j).replace(/(d{3})(?=d)/g, ‘$1’ + t) + (c ? d + Math.abs(n – i).toFixed(c).slice(2) : ”);
};
function escapeRegExp(string) {
   return string.replace(/([.*+?^=!:${}()|[]/\])/g, ‘\$1’);
}
function replaceAll(string, find, replace) {
   return string.replace(new RegExp(escapeRegExp(find), ‘g’), replace);
}

Obviously, my code was a bit different and not setting a hard coded value.

Not too bad, but like I said, way to much work for something so simple.  Maybe a client side library from Infor is coming?   Dare to dream.

 

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

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!