Results 1 to 5 of 5

Thread: creating a hook for bug tracker -> trac integration

  1. #1
    ccfc1986 is offline Member
    Join Date
    Aug 2010
    Posts
    9

    Default creating a hook for bug tracker -> trac integration

    Hey All,

    I am working on a small project to integrate our current SugarCRM (5.2.0.e - we cannot upgrade due to many customizations done to the system breaks upgrades - planning on a clean install and dump of data down the road) with Trac ticketing system.

    My idea was to build a hook based on before_save and so I have done the following:

    Code:
    <?php
    $hook_version = 1;
    $hook_array = Array();
    $hook_array['before_save'] = Array();
    $hook_array['before_save'][] = Array(1, 'TracSync', 'custom/modules/Bugs/TracSync.php', bug_opened, bug_opened);
    ?>
    This works for every time a 'submit' button is basically used within 'Bugs' module right? So with that being the case, I only want NEW bugs to perform this action (create a Trac ticket/bug). So i coded my TracSync.php to have this in it:

    Code:
    if ($bean->status == 'New' && $bean->fetched_row['Status'] == ''){
    //perform actions
    ...
    }
    Is this the best way to go about doing this - and getting this 'on certain actions only' ability? Please let me know if there is another way that might be better.

    Thank you in advance for your help.

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: creating a hook for bug tracker -> trac integration

    If by 'new' you mean newly entered Bug records, this would be a better approach:

    if (empty($bean->fetched_row['id']))

    You are basically inspecting the ID column of the current record. It is only empty in situations where the record is being entered into Sugar for the first time.
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    ccfc1986 is offline Member
    Join Date
    Aug 2010
    Posts
    9

    Default Re: creating a hook for bug tracker -> trac integration

    Thank you for the reply. I have run into another issue for a value that should be set and available within $bean (at least i would be lead to believe so).

    I am trying to access the following variables:
    Code:
                    $platform = $bean->bug_platform_c;
                    $module = $bean->bug_module_c;
    But when i print out the $platform and $module both are blank. I have done a print_r($bean) and i don't see them listed anywhere in there. Is there something I am obviously missing here... are they available within a different variable or something - although i thought all parameters are based and stored in the $bean variable from the bug reporting form?

    Thanks for your help and input again! Much appreciated!

  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: creating a hook for bug tracker -> trac integration

    Can you share the entire logic hook class?

    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.

  5. #5
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: creating a hook for bug tracker -> trac integration

    Quote Originally Posted by ccfc1986 View Post
    Thank you for the reply. I have run into another issue for a value that should be set and available within $bean (at least i would be lead to believe so).

    I am trying to access the following variables:
    Code:
                    $platform = $bean->bug_platform_c;
                    $module = $bean->bug_module_c;
    But when i print out the $platform and $module both are blank. I have done a print_r($bean) and i don't see them listed anywhere in there. Is there something I am obviously missing here... are they available within a different variable or something - although i thought all parameters are based and stored in the $bean variable from the bug reporting form?

    Thanks for your help and input again! Much appreciated!
    Two things come to mind:

    1. The field names are misspelled.

    2. The hook was changed from before_save to after_save
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. creating a hook for bug tracker -> trac integration
    By ccfc1986 in forum Developer Help
    Replies: 1
    Last Post: 2012-01-11, 09:43 PM
  2. Problem creating a process_record hook
    By lcwakeman in forum Developer Help
    Replies: 3
    Last Post: 2010-12-15, 08:18 PM
  3. Creating a configurable logic hook
    By robertbmirth in forum Developer Help
    Replies: 0
    Last Post: 2010-07-30, 05:51 PM
  4. Logic hook on creating new Case
    By azurtec in forum Developer Help
    Replies: 3
    Last Post: 2008-12-11, 04:57 PM
  5. Replies: 2
    Last Post: 2008-06-25, 02:20 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
  •