Page 1 of 1

Negative currency format

Posted: 18 Jul 2019
by Katy
Hi there!
I have a calculated field on the display form in currency format. Users want to see negative numbers in (), i.e.: -$488.64 = ($488.64)
I tried this code:

Code: Select all

function setNegEUR() {
    var eurneg = fd.field('EUR_ReturnCAD').value();

    if (eurneg.indexOf('-') !== -1) {
        eurneg = '(' + eurneg.replace('-', '') + ')';
		alert(eurneg);
    }

    fd.field('EUR_ReturnCAD').value(eurneg);
}

setNegEUR();
The alert shows it fine, but the field is still showing it with "-" .... Can you help please? Is there any easy solution for that? I found this js library, but i thought if i can just do it on the form it would be better.

Re: Negative currency format

Posted: 22 Jul 2019
by mnikitina
Hello Katy!

Please use the following code.

The issue was that you can't replace the field value in the display view. And the rest is working perfectly!

Code: Select all

function setNegEUR() {
    var eurneg = fd.field('EUR_ReturnCAD').value();

    if (eurneg.indexOf('-') !== -1) {
        eurneg = '(' + eurneg.replace('-', '') + ')';
		alert(eurneg);
    }
fd.field('EUR_ReturnCAD').control()._el().text(eurneg);
}

setNegEUR();

Re: Negative currency format

Posted: 23 Jul 2019
by Katy
Awesome! Works great! thank you :-)
Yes, i completely forgot about the display form is not editable per se... :))