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

         $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


$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' =>
                0 =>
                    'widget_class' => 'SubPanelTopButtonQuickCreate',
                1 =>
                    '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?

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

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.