Results 1 to 6 of 6

Thread: Mass update error with decimal and currency fields

  1. #1
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Mass update error with decimal and currency fields

    Hi there,

    im using 5.2 CE and im having an error with massupdate.
    My default decimal separator is: ,
    and thousand separator is: .
    so my currency or float fields are displayed like this: 3.457,22

    When i update records using mass update my fields are all wrong
    i have 3.457.220.000,00 for currency (it adds 6 digits)
    and 3.45.722,00 if it is a float field

    is there a way to fix this or to disable massupdate for this module?
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  2. #2
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Mass update error with decimal and currency fields

    Hi there,

    so i solved this matter only for currency type, when we create a currency field it create as dbtype FLOAT(26,6), doing a little research i changed it to DOUBLE and it works for currency fields, but for Decimal fields im still having the mass update problem, any ideas?
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  3. #3
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Mass update error with decimal and currency fields

    ok so i had to make a logic hook before save to correct this issue for now:

    PHP Code:
        function updateamount(&$bean$event$arguments){
            
            
    //value for massupdate
            
    if($_REQUEST['action'] == 'MassUpdate') { 
            
    $bean->valor= (float)$bean->fetched_row['valor'];

            }  
            
        } 
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  4. #4
    digger72 is offline Junior Member
    Join Date
    Aug 2008
    Posts
    1

    Default Re: Mass update error with decimal and currency fields

    Hi, i have the same Problem with the MassUpdate.
    Please can you tell me where you have placed the hook and the file from where this function is called?

    Big Thanks
    Frank

  5. #5
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Mass update error with decimal and currency fields

    Hi there,

    so the file that calls the function is on

    sugarcrm/custom/modules/<MyModule>/logic_hooks,php

    PHP Code:
    <?php
     $hook_version 
    1
    $hook_array = Array(); 
    // position, file, function 
    $hook_array['before_save'][] = Array(1,'currencymassupdate''modules/<MyModule>/<MyModule>LogicHook.php','<MyModule>LogicHook''currencymassupdate'); 



    ?>
    and the function on the file sugarcrm/modules/<MyModule>/<MyModule>LogicHook.php

    PHP Code:

    <?php

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

    class <
    MyModule>LogicHook {

    function 
    currencymassupdate(&$bean$event$arguments){
        
               
    //currency fields for mass update
            
    if($_REQUEST['action'] == 'MassUpdate') { 
                    
    $bean->valorlancamento = (float)$bean->fetched_row['valorlancamento'];
            }  
            
        }

    }
    you should replace <MyModule> for your module's name. In this case valorlancamento is the name of the field i need to update
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  6. #6
    ifv
    ifv is offline Sugar Community Member
    Join Date
    Oct 2005
    Posts
    17

    Default Re: Mass update error with decimal and currency fields

    I was having similar problems with locale settings (decimal and thousands separators), and, by adding the following on to vardefs.php, I managed to fix the problem:

    PHP Code:
        'disable_num_format' => true
    Resulting in

    PHP Code:
    [...]
      
    'amount' =>
      array (
        
    'name' => 'amount',
        
    'vname' => 'LBL_AMOUNT',
        
    'disable_num_format' => true,   
        
    'type' => 'currency',
        
    'dbType' => 'double',
       )
    [...] 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Decimal precision and currency
    By Iggby in forum General Discussion
    Replies: 6
    Last Post: 2009-12-16, 08:34 PM
  2. Campos Currency, Integer ou Decimal?
    By jorgeluiz in forum Portugese
    Replies: 5
    Last Post: 2008-11-17, 07:10 PM
  3. add fields in Mass Update
    By jenifer in forum Developer Help
    Replies: 2
    Last Post: 2008-06-27, 12:23 PM
  4. How to add more fields to mass update
    By hheckner in forum General Discussion
    Replies: 1
    Last Post: 2006-09-22, 11:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •