Existing Leads Documents Relationship

I would like to allow my users to attach documents to Lead records. I noticed there is already an existing many-to-many relationship between Leads and Documents but the Document subpanel is not appearing in Leads.

Is there something else I must do or can I just add another relationship between Leads and Documents?

That seems to be A BUG @pgr @Mac-Rae

Here is the solution that you can follow and get a Documents Subpanel under Leads Module.

Create a file at /custom/Extension/modules/Leads/Ext/Vardefs/documents_rel.php

Content of this file would be

<?php
         $dictionary['Lead']['fields']['documents'] = array(
								                'name' => 'documents',
								                'vname' => 'LBL_DOCUMENTS',
								                'type' => 'link',
								                'relationship' => 'leads_documents',
								                'source' => 'non-db',
								                'module' => 'Documents',
								            );

 ?>

Create another file at /custom/Extension/modules/Leads/Ext/Layoutdefs/documents_subpanel.php

Content for this would be

   <?php

$layout_defs['Leads']['subpanel_setup']['documents'] = array(
            'order' => 10,
            'module' => 'Documents',
            'subpanel_name' => 'default',
            'sort_order' => 'asc',
            'sort_by' => 'id',
            'title_key' => 'Documents',
            'get_subpanel_data' => 'documents',
            'top_buttons' =>
            array(
                0 =>
                array(
                    'widget_class' => 'SubPanelTopButtonQuickCreate',
                ),
                1 =>
                array(
                    'widget_class' => 'SubPanelTopSelectButton',
                    'mode' => 'MultiSelect',
                ),
            ),
        );

Run Repair/Rebuild and you will see documents subpanel under Leads :slight_smile:

Does the subpanel appear in Studio?

Is it disabled in Admin / Display modules and subpanels?

@pgr
The subpanel does not appear in Studio at all when I go to Admin >> Leads >>> Subpanels

@cherub-chum
Thanks alot for your help. I’ll pass the steps you provided to my techie.

On the offhand my techie is unable to do what you suggested, will there be any issues in the future if I were to simply create a new many-to-many or one-to-many relationship between Leads and Documents?

How about going to Admin - Studio - Open Drop Down Leads - click on relationships

Here you are able to add relationship to documents.

That’s what I would do but there was already an existing many-to-many relationship there. I’m just afraid adding another relationship might mess things up down the road.

Just a few days ago I did set up relationship between Knowledgebase and Documents by Studio and all worked fine. Maybe your subpanel is in hidden section. I just hided knowledgebase subpanel from Documents (used my locla test environment) and after that it did not show up in Studio - Documents - Subpanels … maybe this is reason … hided in Admin - Module and Subpanel show/hide

The relationship is already there, The code i have shared is to just display the subpanel.

1 Like

@cherub-chum thank you so much for the steps you provided. My techie followed your instructions to a T and the Documents subpanel is now visible for each Lead record.

It is unclear if this topic is related to ver 7 or 8, but I noticed few days back that in 8.8.1 this problem still persist.’

I wonder if this solution will work with 8.8.1? (or is it maybe included/resolved in 8.9)

Update: just noticed that suitecrm 8 was relased in 2022, so this thread deals with version 7, I am unhappy to report that the very same issue exists in version 8 (8.8.1 at the time of writing this post).

Just short update, SuiteCRM 8.9 still exhibits same problem (Documents are not visible as subpanel in Leads).

I couldn’t find it in Github, so I took the liberty to add it.

As a quick & dirty workaround without code changes, I’d either use notes in the history panel or add a 2nd relationship.

1 Like

The only difference I noticed is that Documents vs. Leads relationship is slightly different from others:

Screenshot 2025-10-23 083321

In case of other modules, primary module is set to documents and related to the module in question. With Leads is the opposite, and I wonder if this is by mistake or is there a reason for this.

Hi @mrak, it could have been a strategic solution made by SuiteCRM developers because they thought the normal use of a Document would intended to be a collection of many Leads’ data.
Anyway, which is your scenario?

Huh, maybe, I guess you might be right.

My process includes client acquisition and one of the steps includes evaluation of provided documents, so in order for my lead to become client we need to evaluate some materials he is sending us.
So from my perspective this could/would be useful (I also have general issue that I can not archive unused contacts or leads and I really like to have my screens tidy and full with relevant data only; it speeds up the work).

Argument against your conclusion is that documents-leads connection exists and is “coded” into suitecrm by default (relationship exists out of the box). It is just that documents subpanel is not shown (there is a number of posts similar like mine, as well as some offered work ardounds to solve it - unfortunately it includes messing up with code which I try to avoid as much as possible because it will seriously undermine future upgrade processes).

I understand your will to stay as much upgrade safe as possible, and I agree with it.
Do you need to manage multiple versions of each file? If not, you can use the Notes module.
In any case if you need a quick solution without coding, just add a new 1-to-many relationship you desire. Remember that the subpanel will appear on the 1 side

1 Like

Staying up to date is reasonable expectation because of functional and security updates, I do not see anything wrong with this (I actually remain on 8.8.1 because it appears that 8.9 breaks some things which I use, so I am waiting for a fix or next release).

I am repeating this message here in order to make it clear that this issue persist from version to version.

My current setup uses documents in production, switching to notes for some customers while I have thousands of others are with documents seem wrong.

So, what I am looking for is to see if this behaviour is by design (if that is the case I would really like to understand reasoning behind that decision), or a fix.

I am patient and I will wait.

Hi @mrak , only the SuiteCRM mainteiners could give an answer about the strange behavior in the Leads module.

If i may, i suggest you to add that subpanel via code, waiting for the fix to be released

1 Like

There you go :slight_smile:

1 Like

Thank you! It appears that there are a lot of fixes. Really looking forward to your overview video (I listened to your advice and waited).

On other note, I am really happy to see that the pace of updates (and number of updates) is picking up.