Results 1 to 8 of 8

Thread: How to execute a logic hook in EditView??

  1. #1
    EDUCASTREAM is offline Senior Member
    Join Date
    Jul 2009
    Posts
    52

    Default How to execute a logic hook in EditView??

    Is it possible to make a logical Hook who will be fired when you create a new record??

  2. #2
    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: How to execute a logic hook in EditView??

    You can implement either a before_save or after_save logic_hook.
    You can find examples on sugar wiki.

    Kind regards
    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.

  3. #3
    EDUCASTREAM is offline Senior Member
    Join Date
    Jul 2009
    Posts
    52

    Default Re: How to execute a logic hook in EditView??

    before_save and after_save don't fire when I create the record. It only fire when the record is saved.
    When I click on "create contract or create opportunities, the logik is not fired...

  4. #4
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: How to execute a logic hook in EditView??

    They both fire on the initial create. I have several logic hooks that handle only the initial create case by checking if $bean->fetched_row['id'] is set and they are working.

    Please paste the path to your logic_hooks.php file and its contents to this thread. Also paste the path and contents of your class definition file. I have found that it is often an error in the filenames or an if condition within the called function that makes it appear like it did not fire.

    Phil

  5. #5
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: How to execute a logic hook in EditView??

    Use after_retrieve when going to the edit view from clicking a "Create new..." link. Then in the hook do a check to see if the record is new:
    PHP Code:
            if(empty($bean->fetched_row['id'])) {
                return; 
    //Ignore for a new record
            


  6. #6
    EDUCASTREAM is offline Senior Member
    Join Date
    Jul 2009
    Posts
    52

    Default Re: How to execute a logic hook in EditView??

    eggsurplus wrote: Use after_retrieve when going to the edit view from clicking a "Create new.

    How??

  7. #7
    EDUCASTREAM is offline Senior Member
    Join Date
    Jul 2009
    Posts
    52

    Default Re: How to execute a logic hook in EditView??

    For example, How can I make a logic who will print "hello" when I click on "create contract"?

    I can make it when i click on "save" but not when I click on "create..."

    thi logic is like:

    function test (&$bean, $event, $arguments) {
    echo"hello"; exit;}

  8. #8
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: How to execute a logic hook in EditView??

    It's exactly the same as how you do it when you hit save but use after_retrieve instead of after or before_save in your logic_hooks.php for the module. There are plenty of examples on this forum.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to add a logic hook
    By youssefmamdouh in forum Developer Help
    Replies: 3
    Last Post: 2011-09-06, 01:02 PM
  2. Replies: 10
    Last Post: 2010-11-16, 02:41 AM
  3. Replies: 3
    Last Post: 2009-08-15, 03:00 AM
  4. adding custom logic in EditView
    By bandsb in forum Developer Help
    Replies: 3
    Last Post: 2009-01-27, 09:59 PM
  5. Logic Hook
    By sacramentojoe in forum Help
    Replies: 15
    Last Post: 2007-07-31, 11:30 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
  •