Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Error with relationship between Opportunities and Documents v.5.1

  1. #1
    adey is offline Member
    Join Date
    Sep 2008
    Posts
    5

    Exclamation Error with relationship between Opportunities and Documents v.5.1

    We are experiencing an error when creating a link between an opportunity (we've renamed them enquiries) and a document.

    The relationship was created using the studio (one enquiry to many documents).

    Now if we try to create a new document from within the opportunities screen we get the following error:

    Catchable fatal error: Object of class Link could not be converted to string in .../data/SugarBean.php on line 1784

    This line is:

    PHP Code:
    function save_relationship_changes($is_update$exclude=array())
    ...

    $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def [ 'link' ]} = {$this->$def [ 'id_name' ]} " ); 
    The odd thing is we can create a document in the Create Document Screen with a link to the opportunity with no problems - it's just when we are going through the create button on the Opportunity Subpanel.

    Any help would be greatly appreciated.

    Although we get this error the document does still appear, but if we try and view the document we get the error:

    Invalid File Reference

    We are running sugarCRM Version 5.1.0 (Build 4732) on Apache 2.2.8, PHP 5.2.4 on ubuntu with MySQL 5.

  2. #2
    adey is offline Member
    Join Date
    Sep 2008
    Posts
    5

    Thumbs up Re: Error with relationship between Opportunities and Documents v.5.1

    I have managed to solve this myself by deleting out all of the php files created by the relationship and the appropriate tables and records in the database. Then simply re-creating the relationship in studio.

    Obviously, something went wrong when the initial creation of the relationship.

    Files that need to be deleted:

    custom\application\Ext\TableDictionary\tabledictio nary.ext.php
    custom\Extension\application\Ext\TableDictionary\c ustomopportunities_documents.php
    custom\Extension\modules\Documents\Ext\Language\en _us.customopportunities_documents.php
    custom\Extension\modules\Documents\Ext\Layoutdefs\ customopportunities_documents.php
    custom\Extension\modules\Documents\Ext\Vardefs\cus tomopportunities_documents.php
    custom\Extension\modules\Opportunities\Ext\Languag e\en_us.customopportunities_documents.php
    custom\Extension\modules\Opportunities\Ext\Layoutd efs\customopportunities_documents.php
    custom\Extension\modules\Opportunities\Ext\Vardefs \customopportunities_documents.php
    custom\metadata\opportunities_documentsMetaData.ph p
    custom\modules\Documents\Ext\Language\en_us.lang.e xt.php
    custom\modules\Documents\Ext\Layoutdefs\layoutdefs .ext.php
    custom\modules\Documents\Ext\Vardefs\vardefs.ext.p hp
    custom\modules\Opportunities\Ext\Language\en_us.la ng.ext.php
    custom\modules\Opportunities\Ext\Layoutdefs\layout defs.ext.php
    custom\modules\Opportunities\Ext\Vardefs\vardefs.e xt.php
    custom\working\modules\Opportunities\relationships .php

    SQL database:

    drop "opportunities_documents_c" table
    delete record in relationships where join_table="opportunities_documents_c"

    Then a quick repair and rebuild and you should no longer have your relationship.

    Then I was able to re-create the relationships and everything seemed to work fine.

  3. #3
    mezzo is offline Member
    Join Date
    Aug 2008
    Posts
    12

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    Hi,

    I have the same Problem but it used to work fine.

    When I do as you propose what happens with all the documents that are already uploaded ?

    regards, alex

  4. #4
    adey is offline Member
    Join Date
    Sep 2008
    Posts
    5

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    mezzo,

    The documents should remain, but the links to the opportunities (or whatever module your relationship is to) would disappear - this is because you are deleting the "opportunities_documents_c" table.

    If you take a backup of that table before you delete it and then restore the data after it has been recreated by the studio then you should regain the links.

    As always with these kind of things, I STRONGLY recommend that you do what I did and try this out on a test system first to see what results you get and that you can actually restore the data.

    adey

  5. #5
    mezzo is offline Member
    Join Date
    Aug 2008
    Posts
    12

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    Sure Thing my Test system is ready for this test.

    I am wondering if there is no other way of fixing this?

    Regards, Alex

  6. #6
    mezzo is offline Member
    Join Date
    Aug 2008
    Posts
    12

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    I tested on my test site and it did not work for me :-(.

    Is there another solution to this Problem?

    Regards, Alex

  7. #7
    mezzo is offline Member
    Join Date
    Aug 2008
    Posts
    12

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    So after checking on this error I found out the following:

    The relation was build as a account one-to-many Document.

    the relation is set in the dabase table relationships as many-tomany. In the Studio this relation is shown as one-to-many. This confusis me a little bit.

    Now when adding a Document from the Account panel it shows as debug output:

    Mon Nov 10 19:12:11 2008 [5106][1xxx][DEBUG] Relationship type = many-to-many

    sugar works this case as a many-to-many relation although there is a one-to-many.
    LINK.PHP line 674 function _add_many_to_many($add_values)

    this is where I am stck now.

    Anyone has an Idea on this?

  8. #8
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    Have a look at this Developer Blog post that discusses how to manually remove custom relationships.

    http://developers.sugarcrm.com/wordp...ships-and-you/

    In the 5.1.0c patch coming out in December, the Repair Relationships function will clean up orphaned relationships.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

  9. #9
    mezzo is offline Member
    Join Date
    Aug 2008
    Posts
    12

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    I checked out that in a Clean install of 5.1.0b a new created relation does not work. So I figure it does not make sense to remove it manually.

    I tried for
    5.1RC works correct.
    5.1 does not work
    5.1a does not work
    5.1b does not work

    I tried to create a relationship between Accounts and Documents in a complete fresh Sugar Installation.

    The debug log is saying an Error in fionding relationship :

    Mon Nov 10 23:14:59 2008 [6784][1][DEBUG] SugarBean.load_relationships, Loading relationship (accounts_documents).
    Mon Nov 10 23:14:59 2008 [6784][1][DEBUG] SugarBean.load_relationships, Error Loading relationship (accounts_documents).
    Mon Nov 10 23:14:59 2008 [6784][1][DEBUG] SugarBean.load_relationships, Loading relationship (accounts_documents).
    Mon Nov 10 23:14:59 2008 [6784][1][DEBUG] SugarBean.load_relationships, Error Loading relationship (accounts_documents).
    Mon Nov 10 23:14:59 2008 [6784][1][INFO] Query: SELECT * FROM relationships
    WHERE deleted=0
    AND (
    (lhs_module = 'accounts_documents' AND rhs_module = 'DocumentRevisions')
    OR
    (lhs_module = 'DocumentRevisions' AND rhs_module = 'accounts_documents')
    )
    AND relationship_type='many-to-many'

    And somehow the field accounts_dotsaccounts_idb is a complete Sugar Bean Object and not a an id.

    But I do not understand the programming Sugar logic so I don't know if that is the Problem or not. Ithink the
    member variable field_defs of the Sugar Bean Instance is not loaded correctly.

    At this point I am Stuck since I could not figure out how this variable is filled in constructor of this class. If anybody has a hint for me I might try again on the Weekend.

  10. #10
    dwheeler is offline Sugar Team Member
    Join Date
    Sep 2007
    Location
    Cupertino CA
    Posts
    165

    Default Re: Error with relationship between Opportunities and Documents v.5.1

    It seems like there is a problem with the saving of the relationship where the related module is DocumentRevisions rather than Documents. I'm not sure how that came to be, but it should be Fixable.

    If you look in the files listed in this blog post and change the references to "DocumentRevisions" to "Documents" and then do a quick-repair it should work properly.

    The id changing to the record should occur after the relationship is fully loaded.
    - David Wheeler
    Software Engineer

Page 1 of 3 123 LastLast

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
  •