Results 1 to 7 of 7

Thread: Module builder not completing relationship setup?

  1. #1
    purplewave is offline Sugar Community Member
    Join Date
    Feb 2007
    Posts
    33

    Default Module builder not completing relationship setup?

    I've recently needed to make use of the SOAP api to interact with our Sugar installation. Everything was going very smoothly until I needed to set a relationship between a lead and a custom module developed using module builder. The relationship between Leads and my module was setup in the module builder and I know it works through Sugar as many of our employees have used it, the subpanels show up in the correct places, and the database table gets updated when associating a lead to my module.

    However, no matter what I do, I always get a "Module Does Not Exist" error when trying to relate a lead to my custom module through the SOAP api. I threw some debugging code into soap/SoapSugarUsers.php inside handle_set_relationship() to find out which module supposedly doesn't exist. After checking that both the leads and my custom module are available in the $beanList array (and that I've spelled it correctly), I checked $mod->relationship_fields to see that the relationship exists. It doesn't. In fact, the relationship_fields array that is checked from within SoapSugarUsers.php is completely empty for my module despite having setup multiple relationships from Module Builder.

    I added a special case to the handle_set_relationship for associating my module to a lead (much like the contacts/users relationship) and discovered this will cause the SOAP api to report success but it doesn't actually relate the two items since even when assigning the correct database field name to $key, the $mod->save_relationship_changes() call doesn't do anything as it doesn't seem to know anything about the relationship either.

    I'm hesitant to override the save_relationship_changes call in my modules class to add this functionality since it's not very well commented in the SugarBean.php file and I can't afford to break the functionality of the module that currently works. Any thoughts or suggestions on how to fix this would be greatly appreciated.

    Edit: I've also found that the SOAP get_relationships call doesn't return anything at all if I pass Leads and my module's name to it but returns the correct results/errors if you use Leads and a non-custom module. I saw nothing in the SOAP functions that would prevent these calls from working with a custom module so I can only assume it's something I did or a bug with module builder.
    Last edited by purplewave; 2008-02-22 at 04:28 PM.

  2. #2
    antcrm is offline Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    8

    Default Re: Module builder not completing relationship setup?

    Noticed the same and submitted Bug Number: 20087. ( http://www.sugarcrm.com/crm/?option=...d-47c5fb45570a )

    Haven't found time yet to see whether problem lies in the Module Builder (relationships definition) or in the sugar soap code not checking relationships correctly.

  3. #3
    purplewave is offline Sugar Community Member
    Join Date
    Feb 2007
    Posts
    33

    Default Re: Module builder not completing relationship setup?

    I've actually found the issue and just forgot to post.

    Short explanation: I was trying to get the parent information based on the child id which set_relationship doesn't support.

    Long explanation: The "problem" is that I setup my relationship through my custom module in the module builder, making it the parent and Accounts the child. However, I was trying to access set_relationship using Accounts as the parent. The relationship exists but due to the module names being passed in "backwards" sugar is unable to find the correct relationship or database table in which to create the relationship. One of the biggest issues in debugging this was that the error returned was "Module Does Not Exist" but it doesn't say which module (and it doesn't help that the module does exist).

    I eventually broke down and added a new SOAP function that gets the relationship information by passing in the child id. I'm in the process of making this function generic instead of hardcoded values for my custom module and will try to remember to post it here when I'm done.

    Edit: Corrected error message
    Last edited by purplewave; 2008-02-28 at 10:12 PM.

  4. #4
    nickwilkens is offline Junior Member
    Join Date
    Apr 2008
    Posts
    1

    Default Re: Module builder not completing relationship setup?

    Any advice on how to proceed with this issue? I am running 5.0d and have the same problem.

    I would be happy at this point to also hardcode the values, but am not sure where to do this.
    Last edited by nickwilkens; 2008-05-11 at 05:28 PM.

  5. #5
    antcrm is offline Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    8

    Default Re: Module builder not completing relationship setup?

    my workaround (as i recall):

    -export your module created in MB (the installer, not the project), instead of deploy
    -unzip the file and edit SugarModules\modules\your_module\your_module.php
    -below the list of var definitions add (as example, choose modules that you need):
    var $relationship_fields = Array('note_id'=>'notes', 'account_id'=>'accounts');

    -save and zip again
    -upload zip in module loader and install

  6. #6
    tomnzyoung is offline Junior Member
    Join Date
    Jul 2007
    Location
    Christchurch, New Zealand
    Posts
    142

    Default Re: Module builder not completing relationship setup?

    The $relationship_fields array is used by SugarBean to identify the related fields to be updated when the record is saved; at 5.0 this array is hardcoded into each subclass of SugarBean - take a look at any of the standard modules and you'll see it set as part of the definitions. ModuleBuilder at 5.0 doesn't set this array for custom relationships as we only create many-to-many relationships that don't require updating related fields.

    At 5.1 though we now can create one-to-many and many-to-many relationships and so we bumped into this problem when updating ModuleBuilder for the new relationship types. The solution we used was to add a 'save' property to the relate field definitions to be used in SugarBean->save_relationship_changes(), and over time we think we'll move away from the hardcoded approach to this new relate field property for standard modules.

    Cheers,
    Tom

  7. #7
    cainmi is offline Junior Member
    Join Date
    Aug 2008
    Posts
    4

    Default Re: Module builder not completing relationship setup?

    @tomnzyoung,
    I'm not quite sure if I understand your answer - is this issue solved in 5.1? Doesn't seem like it. Any tips?

    @purplewave,
    Just wondering if you got around to generalizing that function you made?

    Thanks guys.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. upgraded to 4.5.1e, received "Metadata for table tracker does not exist"
    By sfgeorge in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2007-09-03, 02:24 PM
  2. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  3. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  4. Replies: 7
    Last Post: 2006-06-06, 07:56 PM
  5. Fatal error: Max
    By spokes2k4 in forum Help
    Replies: 3
    Last Post: 2006-01-15, 03:50 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
  •