I have some code that is used for adding commas into a currency value pulling from a field. This is only working when the pence value is .00, cant figure out why. I cant use the Number.prototype.toLocaleString() method and its not supported by the system im using.
This code works when the decimal places(pence) are .00 if they are anything else it throws the whole code out. Obviously its going to be pulling a lot of different values in some could be 4 digits some could be 6 (not including the pence).
// This is the code with the field
var number =
DataModel.Opportunity.Adviser_Sign_Offs__r_1[0].TotalTransferValue__c;
number = number.toString();
var test = String(number.replace(/(.)(?=(\d{3})+$)/g,'$1,'));
WriteTextLine("£" + test, true, false, false, 'OptionLetterblue14');
// This is the code just as a number value
var number = 85167.55
var test = String(number).replace(/(.)(?=(\d{3})+$)/g,'$1,');
WriteText(test);
I want the output to add in commas where they should be in a currency value eg.
85167.55 output as £85,167.55