It's all about the answers!

Ask a question

How do I format a number in RPE?


Glyn Costello (12920) | asked Mar 15 '22, 9:59 a.m.
edited Mar 15 '22, 10:50 a.m.
RPE 6.0.6.1 iFix 21

Using Rational Publishing Engine Document Studio

Trying to publish a value from RTC > WorkItem > AllExtensions > DisplayValue
Number is provided to RPE as (for example) 1000.10

I want to show this as 1,000.10

I have tried parseFloat(displayValue).toLocaleString('en-GB') but this doesn't work (invalid radix?)
Also tried just displayValue.toLocaleString('en-GB') but this returned [object String]

Any other ways?

Many thanks!

Comments
David Honey commented Mar 15 '22, 10:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please add appropriate tags to this question, thanks.


Glyn Costello commented Mar 15 '22, 10:18 a.m.

I've added a couple more tags

Accepted answer


permanent link
Subramanya Prasad Pilar (4.6k14) | answered Mar 15 '22, 2:33 p.m.

I supposeĀ displayValue is string. In that case, you can use the following Script Expression in RPE:

displayValue.replace(/\B(?=(\d{3})+(?!\d))/g, ",");

Glyn Costello selected this answer as the correct answer

Comments
Glyn Costello commented Mar 18 '22, 5:46 a.m.

Thank you. Shame the JavaScript locale functions don't work.

Your answer


Register or to post your answer.