Currency symbol not showing in account panel

I created a custom currency field and placed it in an account panel via studio but when I populate the field with a value the dollar symbol is not showing. I get 1,000,000.00 instead of $1,000,000.00

Am I missing something or does the currency symbol not show for currency fields?

did you add the “currency” filed also besides the amount?

best regards

Hi Mike,

I created a test field ‘money usd’ and I’m getting a currency symbol in list view, but not detail view which only adds the commas and decimal place but no dollar sign. See the attached images ‘list’ and detail. Also attached, ‘field-detail.jpg’

the list view handles the currency in a different way than detail view, i’m asking you again, do you have the currency field added in the edit view and is selectable when you’re creating/editing an account? the currency field is different from the amount it self, you can have 3 or 4 amount fields in one item but the currency will always be just one

best regards

Hi Mike,

Currency field added to both detail and edit layouts - detail layout attached. But not seeing “$” before dollar amount, though the commas and decimal place are being inserted.

Well, just tested that and remembered that I had the same problem once, even in the Opportunities module you wont have the sign there, only the currency next to the field name, the way you should do it for a custom field is like this:

1- Edit the file custom/modules/Accounts/metadata/detailviewdefs.php, search for your custom field (in my case is amount_c) and replace the line that is commented out:

 array (
          0 =>
          array (
            'name' => 'amount_c',
            'label' => '{$MOD.LBL_AMOUNT} ({$CURRENCY})',
            //'label' => 'LBL_AMOUNT',
          ),
        ),

2- For the above code to work you need to copy the file modules/Accounts/views/view.detail.php to custom/modules/Accounts/views/view.detail.php in that file add the next code right bellow function display(){

$currency = new Currency();
if (isset($this->bean->currency_id) && !empty($this->bean->currency_id))
{
	$currency->retrieve($this->bean->currency_id);
	if ($currency->deleted != 1)
	{
		$this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol);
	}
	else
	{
		$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
	}
}
else
{
	$this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
}

3- Make a quick build and repair

The result will be like this

if you really want to add just the symbol on the left side of the amount, you can create a logic_hook the concatenates the amount with the symbol, let me know if you want this guide too.

best regards

Thanks, Mike.

If you could offer a guide on the option to create a logic_hook that concatenates the amount with the symbol that would be great.

Thanks again…

sorry for the late response, but I can’t find a way to overwrite the currency type field because is a currency type field, the workaround that I found is to create another field, text field (amount_text_c), and just put it in detail view, and using a after_retrieve hook you will grab the value of amount_c and concatenate it with the symbol in amount_text_c, remember to only set the amount_text_c in detail view, not in edit view.

logic_hooks.php

$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = Array(
        //Processing index. For sorting the array.
        1,

        //Label. A string value to identify the hook.
        'after_retrieve example',

        //The PHP file where your class is located.
        'custom/modules/Accounts/logic_hooks_class.php',

        //The class the method is in.
        'logic_hooks_class',

        //The method to call.
        'after_retrieve_method'
    );

logic_hooks_class.php

<?php

    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class logic_hooks_class
    {
        function after_retrieve_method($bean, $event, $arguments)
        {
            $symbol = '$';
            $bean->amount_text_c = $symbol .''. number_format($bean->amount_c, '2');
        }
    }

?>

if you want my opinion, this is ugly, but if what you need, I can’t come up with a better idea

best regards

Thanks, Mike.