Results 1 to 5 of 5

Thread: create case logic hook

  1. #1
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default create case logic hook

    hi there.

    i need a logic hook to create a case evertime a new call is created. it does not need to be related, all i want is that the case subject be the same as the call subject, and for me to add a description in the case description.

    regards

    Paul

  2. #2
    daniel.passarini's Avatar
    daniel.passarini is offline Sugar Community Member
    Join Date
    Apr 2006
    Location
    São Paulo - SP / Brasil
    Posts
    80

    Default Re: create case logic hook

    If you want to create a case everytime a call is created, you have to make a logic hook to Calls.
    create custom/modules/Calls/logic_hooks.php with the following content:
    PHP Code:
    $hook_version 1;
    $hook_array = Array();

    $hook_array['after_save'] = Array();
    $hook_array['after_save'][] = Array(1'create_case''custom/modules/Calls/CallsLogicHooks.php''CallsLogicHooks''create_case',);
    /* you shoud judge what is more apropriated: before_save or after_save */ 
    then, create custom/modules/Calls/CallsLogicHooks.php :
    PHP Code:
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class 
    CallsLogicHooks {
        function 
    create_case(&$focus$event$arguments){
                           
    // code to create a new case
                           // $focus is a Call object, containg the info of the saved call
        
    }

    here is a little description fo the logic hooks' structure:
    PHP Code:
    // LOGIC HOOK QUICK GUIDE:
    $hook_array['before_save'][] = Array(2
    'logic_hook_name'// MUST BE UNIQUE. hint: use the function name
     
    'custom/modules/ModuleName/ModuleNameLogicHook.php'// file that has the logic hook codes
    'ModuleNameLogicHook'// class name. the class written in the file above
     
    'function_name'// function called by the logic hook. This function must be a method from the class above
     
    ); 
    hope it helps
    Daniel de Carvalho Passarini

    "Fascinating" - Dr. Spock

  3. #3
    cmacholz is offline Senior Member
    Join Date
    Sep 2009
    Location
    Missoula, MT
    Posts
    82

    Default Re: create case logic hook

    This logic hook will create a case every time the call is saved.

    Is there a way to check if the bean is saving a NEW record or saving a OLD record?

    thanks

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

    Default Re: create case logic hook

    You could modify it to query for the ID value before it is saved. If it is present, abort the process, if not, continue.
    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)
    ______________________________________________

  5. #5
    iDavide's Avatar
    iDavide is offline Sugar Community Member
    Join Date
    Jan 2012
    Posts
    10

    Default Re: create case logic hook

    Hello everyone, I have followed the various guides I've found, but wrong,
    please help me! : (

    I did:
    files: logic_hook.php Stored in: /sugarcrm/custom/modules/relst_Relazioni_Aziendali

    PHP Code:
    <?php

    $hook_version 
    1;
    $hook_array = Array();
    $hook_array['before_save'] = Array();
    $hook_array['before_save'][] = Array(1'before_save''custom/relst_Relazioni_Aziendali/before_save.php','before''before');


    ?>
    files:before_save Stored in: /sugarcrm/custom/include/relst_Relazioni_Aziendali

    PHP Code:

    <?php 


    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');


        
    mysql_connect("localhost","root","sugarcrm");
        
    mysql_select_db("sugarcrm");



    //global $current_user
    require_once('data/SugarBean.php');
    require_once(
    'modules/relst_Relazioni_Aziendali/relst_Relazioni_Aziendali.php');
    require_once(
    'include/utils.php');

    class 
    before 
    function 
    before (&$bean$event$arguments)
    {

    // as contact you can create any other object of any other module

        //die("mi sono rotto i coglioni");

            
    $query "update jjwg_areas set name = 'CULO' where id = '12'";
            
    mysql_query($query);


    }
    }

    ?>
    I built the custom module with module builder, and I do not understand where the latter will attach themselves to my files, and how do I do so that they are called or seen by the system ... thank you so much!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How make logic hook for create new record
    By meeric in forum Developer Help
    Replies: 6
    Last Post: 2009-01-02, 07:49 AM
  2. Logic hook on creating new Case
    By azurtec in forum Developer Help
    Replies: 3
    Last Post: 2008-12-11, 04:57 PM
  3. after save logic hook for case number
    By tyagiakhil in forum Developer Help
    Replies: 4
    Last Post: 2008-01-09, 09:39 AM
  4. Logic Hook help to create tasks when Case is opened
    By lordforbes in forum Developer Help
    Replies: 3
    Last Post: 2007-03-27, 07:29 PM
  5. Logic Hook create/update
    By dricrm in forum Developer Help
    Replies: 2
    Last Post: 2007-02-13, 08:57 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
  •