Results 1 to 4 of 4

Thread: Logic Hook help to create tasks when Case is opened

  1. #1
    lordforbes is offline Sugar Community Member
    Join Date
    Aug 2006
    Posts
    36

    Default Logic Hook help to create tasks when Case is opened

    Apologies if this is strictly within the realms of Sugar Pro or Enteprise, but on Sugar OS I simply want to define a set of tasks wheever a Case is created. My PHP is hopeless but I do have 20 yrs IT so I thought I'd give it a go... I can see from the forums (good here init?) that perhaps a logic hook to execute custom code after the Case has been saved sounds ideal.

    Problem is, I can see only 3 or 4 examples of a logic hook, including the Deassignment Notification hook, and the advice in the wiki. These dont quite cover what I want to do, which is "after_save" of a Case, for the first time, I want to create a dozen or so tasks. I'm aware of the requirement to have the parent_type of Case and to trap the case_id to match the tasks with the correpsonding case, but to actually write the tasks to the database, should I use the Sugarbean (and if so could I be so cheeky as to ask for an example) or should I simply INSERT the records into the database...

    Naturally I'd like to keep the code standardised if possible, which I guess means using the Sugarbean. I realise some of this code may be available as part of Workflow and therefore if there is a reason for the lack of exmaples then I'll understand.

    Great work - both in terms of the code and the forums....

    Chris
    Sugar 4.5.1 (Bitrock)

  2. #2
    kpit's Avatar
    kpit is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Dec 2005
    Location
    Memphis, TN
    Posts
    996

    Default Re: Logic Hook help to create tasks when Case is opened

    Hello Chris,

    You have found one of the missing logic hooks. I do have a patch I have to put into the baseline code that should address this missing hook.

    SugarCRM did not include the hook originally as the after_save could generate an infinite loop condition. if you alter the bean after_save then try to save the current bean again. I have a method I am developing to detect and trap this type of loop and will fail on an attempt save after in the after_save hook. But this is vaporware at this time.

    The biggest reason for after_save I can see is to create related records using the ID in the saved record. you can do this before the record is saved by creating a GUID and setting it in the bean id ($bean->id = create_guid();) { create_guid() is in include/utils.php } then create the related information based on the id created. This works as a work around for the lack of after_save.
    Last edited by kpit; 2007-03-27 at 04:10 AM.
    Cheers,

    Max W. Blackmer, Jr.

    Blog
    Phone: +1 (901) 672-2694



  3. #3
    lordforbes is offline Sugar Community Member
    Join Date
    Aug 2006
    Posts
    36

    Default Re: Logic Hook help to create tasks when Case is opened

    Thanks for the reply Max ... I can see that most of the work in this area appears to have been responded to by you or Ken ... I'll stick with the before_save option and use the logging to work out the exact syntax to write the tasks away.. If I get this working I can see an opportunity for lots more hooks - I've been telling the clients that cerain functions were not possible but ths logic could open up a world of possibilities..!

  4. #4
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Logic Hook help to create tasks when Case is opened

    Hey Max, be sure to submit the logic hook changes you made via the Contribution Form!!

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 15
    Last Post: 2010-04-01, 04:04 PM
  2. useful logic hook.. php newbie
    By ispytodd in forum Developer Help
    Replies: 8
    Last Post: 2006-12-28, 01:31 PM
  3. Adding Logic Hook to existing
    By Superman in forum Developer Help
    Replies: 2
    Last Post: 2006-12-18, 09:38 PM
  4. Logic Hook Question
    By swhitlow in forum Developer Help
    Replies: 1
    Last Post: 2006-06-04, 04:49 AM
  5. Auto Case Create with E-mail
    By leo@zingotel.com in forum Help
    Replies: 0
    Last Post: 2006-04-21, 08:32 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
  •