Display numeric field with comma

I have a panel that I have added to the company summary screen using a dummy field.

The data comes from CRM and an external database.  All the fields have the type numeric.  It appears that when the panel is displayed, it is ignoring the numeric preferences set in the system.  Therefore, instead of displaying 100,000.00 it is displaying 100000.00.  Is it possible to add something to the screen panel to get these to display with the comma?  I did try to add SQL's FORMAT() to my query.  However, I got a Safe Call exception.

This is what my panel looks like...

Any assistance would be greatly appreciated!  Thank you!!

Parents
  • Hello Michele,

    I recommend using a custom script to do this. You can select any screen that is on that page and use this script. Replace "targets" with all the fields you want to show a comma instead of a period.

    crm.ready(function() {
        const targets = ["comp_credit", "comp_orders"];
    
        for (target of targets) {
            const id = "_Data" + target;
            const elem = $(`#${id}`);
            elem.text(elem.text().replace(".", ","));
        }
    });

    If you don't already know what the field names used for these are, you can right click on the value in your browser and click "inspect element". You should see a span tag with an id inside of it. The id is what you need minus the "_Data" bit.

  • Gabriel:  Thank you for your assistance, I tried the script out and it works.  However, I don't want to replace a period with a comma.  I need to place a comma within a number so that 100000.00 will display as 100,000.00.  Is there a way I can adjust the script to accomplish that?

    Thank you!

  • Oops, I didn't read that carefully enough.

    This is a pretty simple solution but will not work with explorer. Since explorer is being discontinued and most users will be on relatively modern browsers, I can't imagine that will be an issue. 

    crm.ready(function() {
        const targets = ["comp_credit", "comp_orders"];
    
        const options = { 
            minimumFractionDigits: 2,
            maximumFractionDigits: 2 
        };
    
        for (target of targets) {
            const id = "_Data" + target;
            const elem = $(`#${id}`);
            elem.text(Number(elem.text()).toLocaleString('en', options));
        }
    });

    Once again you will have to update the "targets" values with your fields.

    Let me know if that works.

  • Gabriel:  I wanted to report back that this worked for me!  Thank you very much!

Reply Children