Results 1 to 4 of 4

Thread: Editing accounts export fields

  1. #1
    bunglesan is offline Junior Member
    Join Date
    Sep 2008
    Posts
    2

    Default Editing accounts export fields

    Hi,

    I have a problem when exporting the accounts data from sugarCRM. I would need to have all the email addresses assigned to the account to be exported. In the current setup (5.0.0b) no emails are exported along with the account data. I know I would need to edit the account.php file for the export query part, but I am a bit unsure how to get all the emails to come along. Is there anybody who has already done this kind of modification or who knows how to do it?

    All help is appreciated! Thanks!

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Editing accounts export fields

    Hi bunglesan

    Bellow is the code.
    You can copy the code between the andopes change and paste at the appropriate place.

    PHP Code:
        function create_export_query(&$order_by, &$where)
            {
                
    $custom_join $this->custom_fields->getJOIN();
                
    $query "SELECT
                        accounts.*,
                        users.user_name as assigned_user_name "
    ;

    // begin andopes change
                
    $query.= ", GROUP_CONCAT(DISTINCT ea.email_address ORDER BY ea.email_address DESC SEPARATOR ' ') AS email ";
    // end andopes change


                         
    if($custom_join){
                            
    $query .=  $custom_join['select'];
                        }
                        
    $query .= "FROM accounts ";




                if(
    $custom_join){
                        
    $query .=  $custom_join['join'];
                    }
                
    $query .= " LEFT JOIN users
                            ON accounts.assigned_user_id=users.id "
    ;

    // begin andopes change
            
    $query.= " LEFT JOIN email_addr_bean_rel eabr ON accounts.id = eabr.bean_id AND eabr.bean_module = 'Accounts' AND eabr.deleted = 0 INNER JOIN email_addresses ea ON eabr.email_address_id = ea.id AND ea.deleted = 0 ";
    // end andopes change


                
    $where_auto " accounts.deleted=0 ";

                if(
    $where != "")
                        
    $query .= "where ($where) AND ".$where_auto;
                else
                        
    $query .= "where ".$where_auto;

    // begin andopes change
            
    $query.= "GROUP BY accounts.id";
    // end andopes change

               
    if(!empty($order_by)){
                    
    //check to see if order by variable already has table name by looking for dot "."
                    
    $table_defined_already strpos($order_by".");

                    if(
    $table_defined_already === false){
                        
    //table not defined yet, define accounts to avoid "ambigous column" SQL error 
                        
    $query .= " ORDER BY $order_by";
                    }else{
                        
    //table already defined, just add it to end of query
                        
    $query .= " ORDER BY $order_by";    
                    }
                        
                }

                return 
    $query;
            } 
    It is working properly.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    bunglesan is offline Junior Member
    Join Date
    Sep 2008
    Posts
    2

    Default Re: Editing accounts export fields

    That is brilliant. Just what I needed. Thanks a lot!

  4. #4
    kingjatin is offline Senior Member
    Join Date
    May 2010
    Location
    India
    Posts
    35

    Default Re: Editing accounts export fields

    Hi André Lopes,

    I have custom module made for persons, where I have my some custom fields that i enter.

    But when I am exporting the records I get all the fields including the system ones as well.

    I need to limit the number of fields to be exported, can you please let me know of the file or function to modify my custom module.

    thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 2008-05-23, 02:07 PM
  2. Replies: 3
    Last Post: 2006-12-12, 08:43 PM
  3. Replies: 1
    Last Post: 2006-09-11, 03:38 PM

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
  •