Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Logic-hook problem - Teams

  1. #1
    Spinaker is offline Senior Member
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    96

    Default Logic-hook problem - Teams

    Hello!
    I must to create a logic hook for module called CE Teams. I have a Sugar version 5.2.0a On OpenSUSE 11 and CE Teams module version 0.98.1233845152. I have problem with converting the leads - when I convert the lead the "Assigned Team" field in new created contact is blank. When conversion goes Sugar won't copy information form the field "Assigned Team".

    I only know that I must to create a logic hook with something like this:
    if ($_REQUEST['action'] != 'ConvertLead')
    return;

    global $focus;
    $bean->team_id = $focus->team_id
    Unfortunetly I'm not a programmer and I can't understand the logic hooks. And YES - I have readed the DEV manual...

    Any reply will be very hepful.

  2. #2
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Logic-hook problem - Teams

    Here http://www.sugarcrm.com/forums/showpost.php?p=145510 I posted a little tool that will create the hook for you. Then you only need to insert/understand the code inside it.

    The code below (which I posted) basically says if the current action is not convert lead go back and do nothing.
    Otherwise set the team_id of the bean (new target record) = the team id of the focus (the lead).

    M
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  3. #3
    Spinaker is offline Senior Member
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    96

    Default Re: Logic-hook problem - Teams

    I have used Your php script for making a logic_hook.
    I have done before_save logic hook for leads module.
    I have pasted the code which I have quoted uppon (which belongs to You) and I have created a hook.
    Unfortunetly - reaction of Sugar is this same - nothing appears in the Assigned Team in Contacts.

    I have cleared cache, making a quick repair - nothing helps.
    And what is most curious - when I have applied the hook buttons in "module loader" dissapeard

  4. #4
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Logic-hook problem - Teams

    Quote Originally Posted by Spinaker View Post
    I have done before_save logic hook for leads module.
    NOT on the leads module - on the target module - Accounts/Contacts/etc.

    You want to modify the team_id on the TARGET not the SOURCE.
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  5. #5
    Spinaker is offline Senior Member
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    96

    Default Re: Logic-hook problem - Teams

    Fresh instance of sugar, logic_hook on contacts module - this same problem - Assigned Team wan't fill in.

  6. #6
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Logic-hook problem - Teams

    Just create a file /custom/modules/Contacts/ContactsVerify.php with the following code:

    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    class 
    ContactsVerify {
       function 
    CheckValues(& $focus$event$arguments){
          
          global 
    $app_list_strings;
          
    $GLOBALS['log']->debug("KUSKE HOOK CONTACT ".$event);
          
    $GLOBALS['log']->debug("REQUEST:".print_r($_REQUEST,true));
          
    $GLOBALS['log']->debug("FOCUS:".print_r($focus,true));
          
    // ---------------------------------------------------------------------------------------------
    // ---------------------------------------------------------------------------------------------
          
    if($event=="before_save"){
    // ---------------------------------------------------------------------------------------------
    // ---------------------------------------------------------------------------------------------
             
    if ( ($_REQUEST["module"] == "Leads" )  
             &&   (
    $_REQUEST["action"] == "ConvertLead" )  
             &&   (
    $_REQUEST["handle"] == "Save" ) )
             {
                
    $lead_id $_REQUEST["record"];
                require_once(
    'modules/Leads/Lead.php');
                
    $lead = new Lead();
                
    $lead->retrieve($lead_id);
                
    $GLOBALS['log']->debug("LEAD:".print_r($lead,true));
                
                
    $focus->team_id $lead->team_id;
             }
                    
    // ---------------------------------------------------------------------------------------------
    // ---------------------------------------------------------------------------------------------
          
    // end if logic hook is beforesave
    // ---------------------------------------------------------------------------------------------
    // ---------------------------------------------------------------------------------------------
       
    //end function CheckValues
    //end class ContactsVerify
    ?>
    Then open /custom/modules/Contacts/logic_hooks.php and add the following line at the end:

    PHP Code:
    $hook_array['before_save'][] = Array(1'ContactsVerify''custom/modules/Contacts/ContactsVerify.php','ContactsVerify''CheckValues'); 
    OR; if it does not exist write an own /custom/modules/Contacts/logic_hooks.php with following lines of code:

    PHP Code:
    <?php
    $hook_version 
    1
    $hook_array = Array(); 
    // position, file, function 
    $hook_array['before_save'] = Array(); 
    $hook_array['before_save'][] = Array(1'ContactsVerify''custom/modules/Contacts/ContactsVerify.php','ContactsVerify''CheckValues');
    ?>
    That's all...
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


  7. #7
    Spinaker is offline Senior Member
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    96

    Default Re: Logic-hook problem - Teams

    Wow, this works! Thank You very much!
    Vielen Dank!

  8. #8
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Logic-hook problem - Teams

    Thank you Harald - now I can just direct every question about team_id in converting leads to this thread.

    M
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  9. #9
    Spinaker is offline Senior Member
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    96

    Default Re: Logic-hook problem - Teams

    I have another problem, also with the Teams module.
    In QuickCreate view in module Accounts we have an activities, cases etc. and when i click on "create" on any subpanel in QuickCreate there is no "assigned team" field filled.
    I have created a logic_hook, for example for cases:

    if($event=="before_save"){
    // ---------------------------------------------------------------------------------------------
    // ---------------------------------------------------------------------------------------------
    if ( ($_REQUEST["module"] == "Accounts" )
    && ($_REQUEST["action"] == "CasesQuickCreate" )
    && ($_REQUEST["handle"] == "Save" ) )
    {
    $account_id = $_REQUEST["record"];
    require_once('modules/Accounts/Account.php');
    $account = new Account();
    $account->retrieve($account_id);
    $GLOBALS['log']->debug("ACCOUNT:".print_r($account,true));

    $focus->team_id = $account->team_id;
    When I click "create" on the QuickCreateViev in Accounts module there is still no "Assigned team" filled
    What I do wrong?
    THX

  10. #10
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Logic-hook problem - Teams

    You need to add the assigned team/team_id to your QuickCreate layouts.

    You should be able to find many posts here explaining how to add fields to quickcreate forms.

    M
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with a Logic Hook
    By Iggby in forum Developer Help
    Replies: 6
    Last Post: 2009-01-29, 12:01 PM
  2. I have problem regarding logic hook
    By cryptex in forum Developer Help
    Replies: 6
    Last Post: 2008-12-02, 06:41 AM
  3. Can I do this with a logic hook?
    By daerid in forum Developer Help
    Replies: 2
    Last Post: 2008-04-23, 05:49 PM
  4. logic hook problem with workflow and customizations
    By danisugar in forum Developer Help
    Replies: 9
    Last Post: 2008-03-05, 04:30 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
  •