Results 1 to 3 of 3

Thread: Logic Hook - Firing just once

  1. #1
    leowolff is offline Sugar Community Member
    Join Date
    Apr 2009
    Posts
    126

    Default Logic Hook - Firing just once

    Hello, I have implement a logic hook that send an email (based on this sugestion: http://www.redinkdesign.net/node/6) when an event occour.

    I have a custom module called services, and I have to inform the responsible when a new service is created and only that. But if I use after_save logic hook it will send an email not only when a new service is created, but everytime its modified, and I dont want that.

    Does anyone have an idea how to send only 1 email in this case?
    Regards,

    SugarCRM CE v.5.2.0c
    Windows platform
    MySQL v.5.0.37
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

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

    Default Re: Logic Hook - Firing just once

    I had a similar situation a while back with a customization I was making for a client.

    What I ended up doing was create a custom field where I could store a flag that indicated whether or not the e-mail had been sent.

    For example, you could use an integer field whose value is set to 0 by default. When your logic hook triggers, only send it if it is set to 0 and then use the logic hook to update it to 1 or some other value as part of the logic that sends the e-mail. Thus the next time around it shouldn't send it out again.
    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
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Logic Hook - Firing just once

    That's a nice, elegant solution. If the process were to fail sending the email for whatever reason then the user could always go back in and hit save to try to send it again since the send email flag would still be 0. Much better then checking to see if it is a new or existing record on each save.

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: 3
    Last Post: 2009-08-15, 03:00 AM
  3. logic hook
    By atik in forum Developer Help
    Replies: 2
    Last Post: 2009-03-28, 10:47 AM
  4. Help with a Logic Hook
    By Iggby in forum Developer Help
    Replies: 6
    Last Post: 2009-01-29, 12:01 PM
  5. logic Hook up
    By sugar7478 in forum Developer Help
    Replies: 8
    Last Post: 2008-07-11, 02:40 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
  •