Results 1 to 7 of 7

Thread: Logic Hooks

  1. #1
    Rajesh Patel is offline Sugar Community Member
    Join Date
    Sep 2009
    Posts
    35

    Default Logic Hooks

    have install the editlogic hooks but it is not working, i have added the following code using the logic hooks

    The two files are created when "Create and Edit Logig Hooks" plugin is used they are saved in "sugar/custom/modules/CVN". here CVN is my module name which i have created using module builder.

    logic_hooks.php Code

    <?php
    $hook_version=1;
    $hook_array = Array();
    $hook_array['after_save'] = Array();
    $hook_array['after_save'] = Array(1,'save','custom/modules/CVN/save-after_save_mjvn.php','save_class','save_method');
    ?>

    save-after_save_mjvn.php Code

    <?php
    class save_class
    {
    function save_method(&$bean, $event, $arguments=null)
    {
    if ($event != 'after_save') return;
    // Insert your custom logic between these comments

    $sql = "insert into CVN_Details (CVNBookno, CVNno) values ('1','2')";
    $result = $bean->db->query($sql,true);

    // Insert your custom logic between these comments
    }
    }
    ?>

    How do i check whether logic hooks are trigger or not..
    I have read all the documents related to logic hooks but none was found helpful

    Please suggest...

  2. #2
    bickart68 is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    111

    Default Re: Logic Hooks

    You will need to echo a comment to the screen and then kill the hook.

    for example:

    echo "I am inside my hook";
    die();

  3. #3
    sivaprabu is offline Member
    Join Date
    Sep 2009
    Posts
    13

    Default Re: Logic Hooks

    Hi,
    try this coding........

    PHP Code:
    <?php
    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'data/SugarBean.php');
    require_once(
    'include/entryPoint.php');
    class 
    save_class
    {
    function 
    save_method(&$bean$event$arguments=null)
    {
    if (
    $event != 'after_save') return;
    // Insert your custom logic between these comments

    $sql "insert into CVN_Details (CVNBookno, CVNno) values ('1','2')";
    $result $bean->db->query($sql,true);

    or

    $result $GLOBALS['db']->query("insert into CVN_Details (CVNBookno, CVNno) values ('1','2')
    "
    false'Failed to load user preferences');

    // Insert your custom logic between these comments
    }
    }
    ?>

  4. #4
    Rajesh Patel is offline Sugar Community Member
    Join Date
    Sep 2009
    Posts
    35

    Default Re: Logic Hooks

    I tried the code, it is calling the logic hooks in the Leads module but giving error "No after_save_class" found in /sugar/custom/include/utis/LogicHook.php

    In the same way i have use editlogichooks for my custom created module "Covernote" but it is not calling logic hooks from that module.not gving error also

    Please tell me if logic hooks can work on custom created module.

  5. #5
    sivaprabu is offline Member
    Join Date
    Sep 2009
    Posts
    13

    Default Re: Logic Hooks

    PHP Code:
    <?php
     
        
    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
        
        
    $hook_array = array();
     
        
    $hook_array['before_save'] = array();
           
        
    // array(hook execute order, 'hook name', 'hook code location', 'hook code class name', 'hook code function to execute')
        
    $hook_array['after_save'][] = array(1'save_class''custom/modules/CVN/save-after_save_mjvn.php''save_class''save_method');


     
    ?>

    try this..it will help u..

    I thing u did not give correct path or wrong class name please check..

    I am used this coding it worked fine....
    Last edited by sivaprabu; 2009-10-12 at 10:50 AM.

  6. #6
    Join Date
    Oct 2009
    Location
    Bangalore
    Posts
    69

    Default Re: Logic Hooks

    Quote Originally Posted by sivaprabu View Post
    Hi,
    try this coding........

    PHP Code:
    <?php
    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'data/SugarBean.php');
    require_once(
    'include/entryPoint.php');
    class 
    save_class
    {
    function 
    save_method(&$bean$event$arguments=null)
    {
    if (
    $event != 'after_save') return;
    // Insert your custom logic between these comments

    $sql "insert into CVN_Details (CVNBookno, CVNno) values ('1','2')";
    $result $bean->db->query($sql,true);

    or

    $result $GLOBALS['db']->query("insert into CVN_Details (CVNBookno, CVNno) values ('1','2')
    "
    false'Failed to load user preferences');

    // Insert your custom logic between these comments
    }
    }
    ?>

    Hi Sivaprabu,

    I am working on similar requirement by fetching the data from the external database and displaying it in one of the custom module.

    I tried with the "before_retrieve" logic hook. I am able to connect to the external database but, i am not able display the data in the view area.

    Can you please guide me how to display the data iin the custom module and what event i should use?


    Thanks in advance
    --Nagaraj S K

  7. #7
    wdroush is offline Senior Member
    Join Date
    Oct 2009
    Posts
    159

    Default Re: Logic Hooks

    Quote Originally Posted by nagarajkonaguthi@gmail.com View Post
    Hi Sivaprabu,

    I am working on similar requirement by fetching the data from the external database and displaying it in one of the custom module.

    I tried with the "before_retrieve" logic hook. I am able to connect to the external database but, i am not able display the data in the view area.

    Can you please guide me how to display the data iin the custom module and what event i should use?


    Thanks in advance
    --Nagaraj S K
    Actually this would be extremely valuable, I too want to know how to pass information from a logic hook to a view (listview to be specific).

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Logic Hooks
    By chrislynch8 in forum Help
    Replies: 3
    Last Post: 2009-07-16, 11:08 AM
  2. Logic Hooks
    By kalaisugar in forum Developer Help
    Replies: 7
    Last Post: 2009-05-08, 07:55 PM
  3. Logic Hooks
    By highres in forum Italiano
    Replies: 3
    Last Post: 2009-02-01, 05:10 PM
  4. Logic Hooks
    By Delos in forum Developer Help
    Replies: 0
    Last Post: 2008-10-17, 01:01 AM
  5. logic hooks
    By user1000 in forum Developer Help
    Replies: 3
    Last Post: 2008-05-06, 07:51 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
  •