Results 1 to 3 of 3

Thread: after_retrieve logic hook runs my code multiple time

  1. #1
    pravin.agham is offline Senior Member
    Join Date
    Sep 2010
    Posts
    64

    Default after_retrieve logic hook runs my code multiple time

    Hi
    I write after_retrieve logic hook on detail view page.
    In that logic hook I did some save transaction. I Problem in that this hook run multiple time after detail view page is load.

    I echo the sql query and found that my query run 4 time.

    can anybody tell me what is the problem
    my code is below-
    PHP Code:
    <?php
    $hook_version 
    1
    $hook_array = Array(); 
    // position, file, function 

    $hook_array['after_retrieve'] = Array();
    $hook_array['after_retrieve'][] = Array(1'updateNewFlag''custom/modules/Quotes/UpdateNewFlag.php''UpdateFlagLogicHook''updateNewFlag');

    ?>


    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class 
    UpdateFlagLogicHook {
        function 
    updateNewFlag(&$focus$event$arguments) {
        global 
    $current_user;
          
    $query "SELECT id FROM newFlag WHERE record_id = '{$focus->id}' and created_by_userID='{$current_user->id}' and module_name='Quotes'";
            
    $result $focus->db->query($querytrue);

            if(
    $focus->db->getRowCount($result) != 0) { //record is alrady present mark it read i.e 0
                
    $query "UPDATE newFlag set read_status = 0,modified_user_id='{$current_user->id}' WHERE record_id = '{$focus->id}' and created_by_userID='{$current_user->id}' and module_name='Quotes'";
                
    $result $focus->db->query($querytrue);
           }
    //if
        
    else
        {
    //means new record mark as read for that user i.e 0
          
    echo $query "INSERT INTO newFlag (id,record_id,module_name,created_by_userID,modified_user_id,read_status,date_modify) VALUE(uuid(),'{$focus->id}','Quotes','{$focus->created_by}','{$current_user->id}','0',NOW())";
               
    $result $focus->db->query($querytrue);
        }
        }
    //function
    }//class
    ?>

  2. #2
    mtvtaras's Avatar
    mtvtaras is offline Sugar Community Member
    Join Date
    Nov 2009
    Posts
    82

    Default Re: after_retrieve logic hook runs my code multiple time

    Hi pravin.agham,

    I think, the problem is in redefined save feature.
    You can try to find it into Save.php and QuoteFormBase.php

    Cheers

  3. #3
    pravin.agham is offline Senior Member
    Join Date
    Sep 2010
    Posts
    64

    Default Re: after_retrieve logic hook runs my code multiple time

    Hi mtvtaras,

    No there is only one save method.

    Please read http://www.sugarcrm.com/forums/showthread.php?t=19746 .

    They said the its an bug!!.

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: 2012-03-28, 10:07 PM
  2. Example of after_retrieve logic hook
    By leftdrive in forum Developer Help
    Replies: 2
    Last Post: 2010-11-02, 08:14 AM
  3. Please check my logic hook code - Not Firing
    By bstonehill in forum Help
    Replies: 12
    Last Post: 2010-01-22, 04:26 PM
  4. Replies: 0
    Last Post: 2009-05-07, 10:23 AM
  5. after_retrieve logic hook
    By kbrill in forum Developer Help
    Replies: 8
    Last Post: 2007-01-12, 02:10 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
  •