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

Thread: Conditional Subpanel

  1. #1
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Default Conditional Subpanel

    Hello All

    Want to start a new discussion on HOW to achieve the CONDITIONAL SUBPANEL

    Let me make this more clear.....

    Say we have Accounts module, which say in a case used to store two typr of Accounts (say this is the drop down values of Account Type) - Service based & Product based. (there can be more, but for this example we will concentrate only for two types).
    Now in detail vioew for Accounts say we want to have subpanels ---

    Case Subpanel when Account type is Service based
    OR
    Product subpanel when Account type is Product based

    Which all means that is Acct type is service based, it shall not show Product based and similarly in product based not to show Case subpanel.

    (Ken may be initial response from your end, you can point us to some related thread/wiki on this topic)

    Lets keep our discussion initiated for from Sugar 5.0 on LAMP or WAMP does not make difference. But yes friends are open to have their suggestion/solution for ver 4.5 also, and ofcourse for 5.1 moving ahead.


    Thanks
    Bipul
    webNET (Let's give the community back their share)
    Bangalore, INDIA

  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: Conditional Subpanel

    Hi Bipul

    Good point!

    The code bellow is the implemented rule for a customer. It works like a charm. It is not necessary to implement anything else.
    It works for SugarCRM CE 5.*

    PHP Code:
    $layout_defs["Accounts"]["subpanel_setup"]["up1_publisers"] = array (
        
    'order' => '01',
        
    'module' => 'UP1_publisers',
        
    'subpanel_name' => 'forAccounts',
        
    'get_subpanel_data' => 'up1_publisers'//dados da tabela
        
    'add_subpanel_data' => 'id',//campo id do módulo que fica no sub-painel
        
    'title_key' => 'LBL_PUBLISHERS_SUBPANEL_TITLE',//colocado dentro do language do módulo que contém o subpainel
    );

    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_agency"] = array (
        
    'order' => '06',
        
    'module' => 'UP2_InsertionOrders',
        
    'subpanel_name' => 'default',
        
    'get_subpanel_data' => 'up2_insertionorders_agency',
        
    'add_subpanel_data' => 'id',//campo id do módulo que fica no sub-painel
        
    'title_key' => 'LBL_IO_WITH_AGENCY_SUBPANEL_TITLE',//colocado dentro do language do módulo que contém o subpainel
    );

    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_advertiser"] = array (
        
    'order' => '07',
        
    'module' => 'UP2_InsertionOrders',
        
    'subpanel_name' => 'default',
        
    'get_subpanel_data' => 'up2_insertionorders_advertiser',
        
    'add_subpanel_data' => 'id',//campo id do módulo que fica no sub-painel
        
    'title_key' => 'LBL_IO_WITH_ADVERTISER_SUBPANEL_TITLE',//colocado dentro do language do módulo que contém o subpainel
    );

    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_publisher"] = array (
        
    'order' => '08',
        
    'module' => 'UP2_InsertionOrders',
        
    'subpanel_name' => 'default',
        
    'get_subpanel_data' => 'up2_insertionorders_publisher',
        
    'add_subpanel_data' => 'id',//campo id do módulo que fica no sub-painel
        
    'title_key' => 'LBL_IO_WITH_PUBLISHER_SUBPANEL_TITLE',//colocado dentro do language do módulo que contém o subpainel
    );
    global 
    $focus;

    if(isset(
    $focus) && is_object($focus) && isset($focus->module_dir) && $focus->module_dir == 'Accounts') {
        if(
    $focus->organisation_type_id_c != '3') {
            unset(
    $layout_defs["Accounts"]["subpanel_setup"]["up1_publisers"]);
            unset(
    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_publisher"]);
        } else if(
    $focus->organisation_type_id_c != '1') {
            unset(
    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_agency"]);
        } else if(
    $focus->organisation_type_id_c != '2') {
            unset(
    $layout_defs["Accounts"]["subpanel_setup"]["up2_insertionorders_advertiser"]);
        }

    Cheers
    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
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Default Re: Conditional Subpanel

    Hi André ,

    Many thanls for the example & code. This ofcourse wil be a good begining for people like me who are stuck at some point.

    Just need one more small help.

    I have a custom module called new_mod, which has a Account related field (account_id(type-id) & accountname (type-relate). I can pick and stick a account_name in new_mod module. But not getting subpanel for same in Accounts. Please help where am I missing.

    Regards
    BIPUL

  4. #4
    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: Conditional Subpanel

    Hi BIPUL

    Please, attach in your next post the files related to the subpanel:

    custom/modules/Accounts/Ext/Layoutdefs/layoutdefs.ext.php
    custom/modules/Accounts/Ext/Vardefs/vardefs.ext.php
    modules/new_mod/vardefs.php

    Cheers
    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.

  5. #5
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Default Re: Conditional Subpanel

    Hi André,

    Thanks again!
    Your indication for th three files gives me where I was wrong.....

    I actucaly was using the wrong name in relation field. Now I am getting the Subpanel....

    Here's teh code in three files (for benefit of friends who wil come here in search of similar concern)

    custom/modules/Accounts/Ext/Layoutdefs/layoutdefs.ext.php
    Code:
     
    $layout_defs['Accounts']['subpanel_setup']['new_module'] = array(
    	'order' => 70,
    	'module' => 'New_Module',
    	'subpanel_name' => 'default',
    	'refresh_page' => 1,
    	'get_subpanel_data' => 'new_modules',  // matches the name of the link field
    	'title_key' => 'LBL_SUBPANEL_MODULE',
    	'top_buttons' => array(
    		array('widget_class' => 'SubPanelTopCreateButton'),
    		array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect')
    	),
    );
    custom/modules/Accounts/Ext/Vardefs/vardefs.ext.php
    Code:
     
    $dictionary["Account"]['fields']['new_module'] = array (
    'name' => 'new_module',
    'type' => 'link',
    'relationship' => 'new_module_accounts',
    'source'=>'non-db',
    'vname'=>'LBL_MEETING',
    );
    modules/new_mod/vardefs.php
    Code:
     
    'accounts" => array (
      'name' => 'accounts',
      'type' => 'link',
      'relationship' => 'new_module_accounts',
      'source' => 'non-db',
    );
    BUT....BUT something somewhere I am missing...I am getting the Subpanels, but then it shows me all the records, and not ONLY the connected records.....

    Do I need to paste some other files/codes.

    Thanks for the help

    Regards
    Bipul

  6. #6
    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: Conditional Subpanel

    Hi Bipul

    You need to rebuild relationships.

    Cheers
    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.

  7. #7
    veronicakatz is offline Senior Member
    Join Date
    Sep 2008
    Location
    Madrid - Spain
    Posts
    71

    Default Re: Conditional Subpanel

    Hi, André.

    I had the same need, I followed your instructions, and everything worked ok! Thanks a lot.
    But... whenever I clear template data cache and then rebuild relationships, I loose the conditional relationship.

    What I did was as follows:
    1) I edited file
    C:\xampp\htdocs\sugarcrm\custom\modules\Project\Ex t\Layoutdefs\layoutdefs.ext.php
    (I added the conditional rules at the end)
    By the way: at the beginning of the file, it says " //WARNING: The contents of this file are auto-generated". This means that there's somewhere else the file is taking the info from.
    2) I rebuilt relationships
    3) everything worked ok

    Whenever I clear template data cache, the lines I wrote at the end of the file are cleared.
    I guess I have to edit another file.. but which one?

    Thanks a lot in advance,
    Veronica

  8. #8
    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: Conditional Subpanel

    Hi Veronica

    You need to edit the file C:\xampp\htdocs\sugarcrm\custom\Extension\modules\ Project\Ext\Layoutdefs\layoutdefs.ext.php instead. The file you edited is generated when Rebuilding Extension and all its content is erased.

    Cheers
    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.

  9. #9
    veronicakatz is offline Senior Member
    Join Date
    Sep 2008
    Location
    Madrid - Spain
    Posts
    71

    Default Re: Conditional Subpanel

    Hi, André
    I did what you said, but I'm afraid it still happens the same.

    As soon as I clear template data cache and then rebuild relationships, I loose the changes in
    C:\xampp\htdocs\sugarcrm\custom\modules\Project\Ex t\Layoutdefs\layoutdefs.ext.php

    although they still remain in
    C:\xampp\htdocs\sugarcrm\custom\Extension\modules\ Project\Ext\Layoutdefs\layoutdefs.ext.php

    (by the way: this last file didn't exist, I had to copy it from the folder I mentioned before).

  10. #10
    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: Conditional Subpanel

    Hi Veronica

    Did you run Rebuild Extension after creating the file custom/Extension/modules/Project/Ext/Layoutdefs/layoutdefs.ext.php?

    Cheers
    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.

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. Subpanel NOT displaying duplicate entries
    By Durrill in forum Developer Help
    Replies: 2
    Last Post: 2012-03-29, 10:46 AM
  2. Replies: 1
    Last Post: 2008-06-18, 05:41 PM
  3. HOWTO - Hack Sugar to support related module info in subpanel (one-many)
    By kenneth.thorman in forum Developer Tutorials
    Replies: 35
    Last Post: 2008-06-10, 07:51 AM
  4. Replies: 4
    Last Post: 2007-09-10, 02:14 PM
  5. Additional but identical Subpanel
    By c5003153 in forum Help
    Replies: 0
    Last Post: 2007-08-01, 02:29 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
  •