Negative currency format

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Katy
Posts: 145
Joined: Wed Dec 02, 2015
Location: Canada

18 Jul 2019

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.

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

22 Jul 2019

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();

Katy
Posts: 145
Joined: Wed Dec 02, 2015
Location: Canada

23 Jul 2019

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests