Results 1 to 4 of 4

Thread: Is this simple search impossible?

  1. #1
    craig4wd is offline Member
    Join Date
    Oct 2006
    Posts
    5

    Default Is this simple search impossible?

    I'm tearing my hair out - please tell me there is a way to.....

    1. Search for all Accounts in a specific Industry

    2. Retrieve the Contact names from the resultant search and export them

    How would I do this?

  2. #2
    madaboutsugar is offline Sugar Community Member
    Join Date
    Apr 2007
    Posts
    19

    Default Re: Is this simple search impossible?

    hi,

    your first problem has solution if u do some simple customisation through studio option in admin....
    and i dont get why u have trouble in importing searched contacts
    as soon as u search the contact just tick the contacts and select import...

    -John

  3. #3
    mlambert is offline Junior Member
    Join Date
    Aug 2008
    Posts
    1

    Default Re: Is this simple search impossible?

    I think he means exporting only the contacts relevant to the accounts search results.
    I'd like to be able to do that, too...

    And how can you customise what fields get exported into the spreadsheet? I know I could just delete the unwanted columns in the spread sheets, but it's a bit fiddley and I'd also like to add some custom fields to the resulting spreadhseet...

    Thanks

  4. #4
    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: Is this simple search impossible?

    Quote Originally Posted by craig4wd
    I'm tearing my hair out - please tell me there is a way to.....

    1. Search for all Accounts in a specific Industry

    2. Retrieve the Contact names from the resultant search and export them

    How would I do this?
    Hi, craig4wd

    1. Search for all Accounts in a specific Industry: I believe you have already done it.

    2. Retrieve the Contact names from the resultant search and export them.
    You have to:
    2.1. Create a controller for the Contacts module: Create the file custom/modules/Contacts/controller.php. The controller should have a function just like that:

    PHP Code:
        function action_listview(){
            
            
    $this->view_object_map['bean'] = $this->bean;
            
            
    $this->view 'list';
            
    $GLOBALS['view'] = $this->view;

            
    $this->bean = new AnotherBean();
        } 
    This class (AnotherBean) is a class which extends the Contact class and override the function create_new_list_query, defined into data/SugarBean.php
    You can override this function, calling the one defined into SugarBean and only make available the created query into $_SESSION. This new $_SESSION entry can be accessed by the action ExportContacts you will create.
    2.2. Create a custom view.list.php: duplicate the include/MVC/VIew/views/view.list.php and paste to custom/modules/Contacts/views. Modify the constructor just like in modules/Activities/views/view.list.php
    2.2.1. In the display function you have to instantiate the $lv from a custom ListVIew derived from include/ListView/ListViewSmarty.php. Just copy this file with another name and remove all functions, preserving just the constructor, which will be modified the enough.
    2.2.2. Copy the function buildExportLink from include/ListView/ListViewDisplay and copy it to the new ListView Class.
    Add another button, the Export Contacts, which will points to another action you will create.
    2.3. Create a new action: At this action you can access the $_SESSION to retrieve the generated query, run it and gets the contacts name from DB. After saving all contacts into the variable $string, just add this lines at the end of the file:

    PHP Code:
    $badoutput ob_get_contents();

    if(
    strlen($badoutput) > 0) {
        
    ob_end_clean();
    }

    header("Pragma: cache");
    header("Content-type: application/octet-stream; charset=".$locale->getExportCharset());
    header("Content-Disposition: attachment; filename=ad_delivery_import.csv");
    header("Content-transfer-encoding: binary");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT" );
    header("Cache-Control: post-check=0, pre-check=0"false );
    header("Content-Length: ".strlen($string));

    print 
    $locale->translateCharset($string'UTF-8'$locale->getExportCharset());

    sugar_cleanup(true);

    echo 
    $string
    Hope this help you.
    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Small problem with Search fields.
    By Napalm Dalmer in forum Help
    Replies: 0
    Last Post: 2007-01-10, 05:57 PM
  2. Contacts Search Form
    By wjohnson in forum Help
    Replies: 3
    Last Post: 2006-11-15, 08:16 PM
  3. BUG In Search/Edit Layout???
    By tj@estreet.com in forum Help
    Replies: 13
    Last Post: 2006-06-10, 05:43 AM
  4. Search or not search ?
    By dadevoti in forum General Discussion
    Replies: 5
    Last Post: 2005-07-25, 12:25 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
  •