Results 1 to 8 of 8

Thread: Custom Export Queries

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

    Default Custom Export Queries

    Hi All,

    I have made a custom module in SugarCRM 5.5 and wrote a custom query for extracting limited number of data from the table, so I have modified the function in root\Sugarcrm\include\SugarObjects\templates\basic \basic.php and modified the following function

    function create_export_query($order_by, $where){
    $custom_join = $this->custom_fields->getJOIN();

    $query = "SELECT first_name, last_name, id, test FROM emp_employee_asset_tracking ";

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

    if($custom_join){ $query .= $custom_join['join']; }

    $where_auto = " emp_employee_asset_tracking.deleted=0 ";

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

    if(!empty($order_by)) $query .= " ORDER BY $order_by";

    return $query;

    }

    The above code is working perfectly fine in terms of extracting the data, now here comes the tricky part.

    Now I have made another custom module and now if I am trying to export the data out of it then it is giving me error because I have written the custom code.

    I have tried various things like If condition to let the system understand that I want to run my above mentioned query when I press export from first module and when i am in second module then I should be able to fetch out table from its table also.

    Please anyone can help a way out for this, what condition should I put to distinguish between my two modules for their own custom queries.

    Thank you...
    __________________
    Cheers !!
    Cheers !!

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Custom Export Queries

    Perhaps it would be a better idea to write your query extension in the bean module itself and not in the include\SugarObjects\templates\basic \basic.php file.
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


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

    Default Re: Custom Export Queries

    Hi,

    Thank you for the reply but can you please let me know where exactly I need to do the modification so that my both of the modules can give the custom export results.

    Thank you...

    Also I have a module named Employee Database where some users enter the records of the employee, now I want to have a validation at the time of saving of the record...that if there is any employee ID that they are entering already exists in the database or not...this functionality is working when we create a new user...I want to have a similar functionality Pls Pls

    Thank again will really appreciate your response to my query..

    Regards
    Cheers !!

  4. #4
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Custom Export Queries

    If you need that customization only for the employees module you should insert your modified create_export_query-function in /modules/Employees/Employee.php and restore the original content of include\SugarObjects\templates\basic\basic.php.
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


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

    Default Re: Custom Export Queries

    There are two custom modules of mine
    1) Employee Database
    2) resource Management

    and I need the custom export for both of these modules and the first one is the template for the Person and second one is basic.

    So where exactly should I put the code like in custom/modules/emp_employee_asset_tracking/ ??? where

    Thank you
    Cheers !!

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

    Thumbs up Re: Custom Export Queries

    Thanks man...modifying the main module's bean file did my work...

    Great stuff many thanks !!!

    But my second query still remains unanswered as how do I check for the duplicate records while saving a record.

    Regards
    Cheers !!

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

    Red face Re: Custom Export Queries

    Quote Originally Posted by kingjatin View Post

    But my second query still remains unanswered as how do I check for the duplicate records while saving a record.

    Regards
    Hi Kuske,

    Please help me in this regard.

    Thank you
    Cheers !!

  8. #8
    snikwahj is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    38

    Default Re: Custom Export Queries

    Quote Originally Posted by kingjatin View Post
    I have a module named Employee Database where some users enter the records of the employee, now I want to have a validation at the time of saving of the record...that if there is any employee ID that they are entering already exists in the database or not...this functionality is working when we create a new user...I want to have a similar functionality Pls Pls
    You have got the clue in your question

    You simply need to override the save function in your custom bean - check out the override of save in modules/Users/User.php to see what to do. You can do your check in that function and then choose to run the parent::save directly, edit the bean first or to do something else depending on whether you find existing records or not.

    HTH.

    JH.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Custom Export Queries
    By kingjatin in forum Developer Help
    Replies: 1
    Last Post: 2010-06-21, 03:36 AM
  2. Using SQL queries on a custom module
    By Advari in forum Help
    Replies: 0
    Last Post: 2010-05-24, 07:55 AM
  3. Logical data model and custom queries
    By CrazyHarry in forum Developer Help
    Replies: 1
    Last Post: 2009-05-08, 10:14 PM
  4. Custom export function or logic hook for export?
    By ivit in forum Developer Help
    Replies: 1
    Last Post: 2009-03-22, 08:22 PM
  5. Custom Queries
    By kbrill in forum Developer Help
    Replies: 6
    Last Post: 2006-09-13, 12:13 PM

Tags for this Thread

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
  •