Results 1 to 4 of 4

Thread: Linking Projects and Documents...nothing but trouble!

  1. #1
    GameboyRMH is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    70

    Unhappy Linking Projects and Documents...nothing but trouble!

    I'm trying to create a relationship between the Projects and Documents modules (one project to many documents), but I'm getting nothing but trouble every step of the way.

    When I try to rebuild the relationships (After changing projects' vardefs.php) the rebuild stops at "feeds" (right before projects) and then most of the modules won't work until I comment out my custom code and rebuild again.

    Here's the code I put under the Relationships section in the vardefs, which alone was enough to stop the rebuild:

    Code:
    	'projects_documents' => array(
            'lhs_module' => 'Project',
            'lhs_key' => 'id',
            'rhs_module' => 'Documents',
            'rhs_key' => 'document_id',
            'relationship_type' => 'one-to-many',
           	),
    Here's what I put in the vardefs body, rebuild crashes with or without:

    Code:
    'document_link' =>
            array(
            'name' => 'Documents',
            'type' => 'link',
            'relationship' => 'projects_documents',
            'module' => 'Documents',
            'bean_name' => 'aDocument',
            'source' => 'non-db',
            'vname' => 'LBL_DOCUMENTS',
            ),
    Also if I add this custom subpanel to Project/metadata/subpaneldefs.php, the subpanels in the Project detail view won't show.
    Code:
    'therevisions' => array(
                    'top_buttons' => array(
                                    array('widget_class' => 'SubPanelTopCreateRevisionButton'),
                                    ),
                    'order' => 10,
                    'sort_order' => 'desc',
                    'module' => 'DocumentRevisions',
                    'subpanel_name' => 'default',
                    'title_key' => 'LBL_DOC_REV_HEADER',
                    'get_subpanel_data' => 'revisions',
                    'add_subpanel_data' => 'document_id',
                    'fill_in_additional_fields' =>true,
                    ),
    I think I've read everything there is to read on module relationships and custom subpanels but I'm stumped!

    Here's the info

    Server: Fedora
    Sugar Suite version: 5.0.0 beta 2
    Webserver: Apache 2.2.6
    Sorry don't know the MySQL version :\

  2. #2
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: Linking Projects and Documents...nothing but trouble!

    Did you create the relationship table?

    projects_documents

    is your sugarcrm.log showing any errors?

  3. #3
    GameboyRMH is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    70

    Default Re: Linking Projects and Documents...nothing but trouble!

    I hadn't created a table actually, most of the guides to linking modules give the impression that you only need to create a table for many-to-many relationships, but now that I look at this more carefully I see that there always needs to be a table for a relationship. That was probably the issue, I'll add the table and see how it goes.

    edit: now that I've researched this a little more it seems I could do this with or without a table, and I just found that the code I used in the vardefs body is wrong.

    Thanks
    Last edited by GameboyRMH; 2007-11-12 at 01:29 PM.
    Server: Fedora
    Sugar 5 CE
    Apache 2.2.6
    MySQL 5.0.27

  4. #4
    GameboyRMH is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    70

    Default Re: Linking Projects and Documents...nothing but trouble!

    OK I've made some progress...I decided to do it without a new table for the relationship, and I'm getting the relationships to rebuild successfully now. I created a new field in Documents called related_project_c, which is a relate type field.

    Here's what I added to the Project/vardefs.php body:
    Code:
      'documents' =>
            array(
            'name' => 'documents',
            'type' => 'link',
            'relationship' => 'project_documents',
            'module' => 'Documents',
            'bean_name' => 'aDocument',
            'source' => 'non-db',
            'vname' => 'LBL_DOCUMENTS',
            ),
    I used this in the Relationships section of Project/vardefs.php:

    Code:
            ,'project_documents' => array(
            'lhs_module' => 'Project',
            'lhs_table' => 'project',
            'lhs_key' => 'id',
            'rhs_module' => 'Documents',
            'rhs_table' => 'documents',
            'rhs_key' => 'related_project_c',
            'relationship_type' => 'one-to-many',
            ),

    I even got the Documents subpanel to show in the Projects detail view, but the relationship in vardefs was set with both lhs_key => id and rhs_key=> id, which of course didn't show any documents inside the subpanel. Here's the problem, when I set rhs_key to my new relate field related_project_c, I get this error displayed in the subpanel area:

    Code:
    Error running count query for Project List: Query Failed:( SELECT count(*) c FROM documents where ( documents.related_project_c= 'cb7df11f-04c4-8fa4-2a8f-47388b9d7129' AND documents.deleted=0) AND documents.deleted=0 )::MySQL error 1054:
    I get this error regardless of the subpanel settings. Seems like it thinks related_project_c doesn't exist. Is there something else I need to rebuild? Here's what I added to Project/metadata/subpaneldefs.php


    Code:
                  'documents' => array(
                    'top_buttons' => array(
                                    array('widget_class' => 'SubPanelTopCreateRevisionButton',popup_module => 'Documents'),
                                    ),
                    'order' => 10,
                    'sort_order' => 'desc',
                    'module' => 'Documents',
                    'subpanel_name' => 'default',
                    'title_key' => 'LBL_DOCUMENTS',
                    'get_subpanel_data' => 'documents',
                    'add_subpanel_data' => 'related_project_c',
                    'fill_in_additional_fields' =>true,
                    ),
    Last edited by GameboyRMH; 2007-11-12 at 06:11 PM.
    Server: Fedora
    Sugar 5 CE
    Apache 2.2.6
    MySQL 5.0.27

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Attaching documents to Cases/Projects/etc
    By Kalendrinn in forum Feature Requests
    Replies: 15
    Last Post: 2009-10-22, 10:48 AM
  2. Projects and documents
    By enjoy777 in forum Project Management
    Replies: 2
    Last Post: 2008-08-24, 11:27 PM
  3. Replies: 1
    Last Post: 2006-01-11, 01:41 PM
  4. Replies: 4
    Last Post: 2005-08-28, 12: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
  •