Results 1 to 3 of 3

Thread: How to create relationships in modulebuilder with existing modules as primary

  1. #1
    edg
    edg is offline Sugar Community Member
    Join Date
    Feb 2007
    Location
    Atlanta, GA
    Posts
    46

    Post How to create relationships in modulebuilder with existing modules as primary

    I'm putting this one in the undocumented feature category.

    Here's the challenge: I wanted to create a relationship between Accounts and a custom module in modulebuilder. Modulebuilder allows the set up of relationships with existing modules as long as the custom module is the primary module (left hand side).

    However, you can establish a relationship in modulebuilder where the custom module is the right hand side by following these simple steps:

    1) Establish the relationship where the custom module is the primary.

    2) Edit the relationships.php file in the packages module directory and reverse the roles (custom/modulebuilder/packages/<yourpackage>/module/<custom-module>/relationships.php).

    3) Deploy the module as usual. The relationship will be created as if it were done in studio.

    For example, with a custom module called Subscribers that has a many-to-one relationship with Accounts, establish the subscribers_accounts relationship in modulebuilder. This creates the following code in relationships.php:

    Code:
    <?php
    $relationships = array (
      'subscribers_accounts' =>
      array (
        'rhs_label' => 'Accounts',
        'rhs_subpanel' => 'default',
        'lhs_module' => 'Subscribers',
        'rhs_module' => 'Accounts',
        'relationship_type' => 'one-to-many',
        'readonly' => false,
        'deleted' => false,
        'relationship_only' => false,
        'for_activities' => false,
        'is_custom' => false,
        'relationship_name' => 'subscribers_accounts',
      ),
    );
    ?>
    Now, reverse the relationship to setup the correct relationship.

    Code:
    <?php
    $relationships = array (
      'accounts_subscribers' =>
      array (
        'rhs_label' => 'Subscribers',
        'rhs_subpanel' => 'default',
        'lhs_module' => 'Accounts',
        'rhs_module' => 'Subscribers',
        'relationship_type' => 'one-to-many',
        'readonly' => false,
        'deleted' => false,
        'relationship_only' => false,
        'for_activities' => false,
        'is_custom' => false,
        'relationship_name' => 'accounts_subscribers',
      ),
    );
    ?>
    Then deploy the module as usual through modulebuilder and the relationship will be created.

  2. #2
    cyberrodent is offline Sugar Community Member
    Join Date
    Aug 2005
    Posts
    10

    Default Re: How to create relationships in modulebuilder with existing modules as primary

    Thanks for posting this -- this will be a huge help. I was facing having to establish a number of relationships after installing the module! Sugar should bake this into the module builder when they can.

  3. #3
    ivit is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    187

    Default Re: How to create relationships in modulebuilder with existing modules as primary


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Customizations to published modules (from ModuleBuilder)
    By jim.thornton in forum General Discussion
    Replies: 0
    Last Post: 2009-03-13, 05:29 AM
  2. HOWTO - Enhance ModuleBuilder generated modules to include AJAX
    By kenneth.thorman in forum Developer Tutorials
    Replies: 10
    Last Post: 2009-01-16, 05:53 PM
  3. Replies: 5
    Last Post: 2008-10-15, 03:18 PM
  4. Custom module, existing schema & relationships
    By martinhewitt in forum Help
    Replies: 2
    Last Post: 2008-06-30, 10:31 AM
  5. HOWTO - Enhance modulebuilder - Create AJAX enables modules/subpanels
    By kenneth.thorman in forum Developer Tutorials
    Replies: 1
    Last Post: 2008-06-09, 07:13 PM

Tags for this Thread

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
  •