Existing database table for custom module

I am trying to develop a custom module from module builder using existing module(lets say Contacts) database table. How can I achieve this?

Hey there,

Have you found a solution for this?

I wanted to double check which of the following you’d like to achieve?:

  • A Custom Module with the same Fields as Contacts
  • A Custom module with the same Fields & Data as Contacts

I’m not 100% sure if you can fully copy-paste a Module, as the CRM would have a lot of behind-the-scenes logic that the Module would be involved with that would be affected

However, if you use the Module Builder, you should be able to use the “Person” module template.

This would add most, if not all, of the Out-of-the-box Contact fields into the new module.

So, when creating a Custom Module, select this:

The module that is created will contain the following fields:

If you want the same Data, from here, you should be able to simply Export the Contact Records and import them into the newly created Custom Module
(As long as you have made it importable, and it has the same fields as Contacts)

Is this what you’d like to achieve?
Or have i maybe missed something?

Hi, thanks for your effort for explaining! Lets say I wanted to build a custom module ‘test_contact’ from module builder! What I am trying to do is for the module ‘test_contact’, I wanted to use the database table ‘contacts’ of module ‘Contacts’. I don’t want to replicate the fields of module ‘Contact’! Instead, I wanted to use and define db table ‘contacts’ in module ‘test_contact’.
The same thing I found in module ‘Employees’. In the module ‘Employees’, the vardefs.php of module Users is defined in Employees. Can I achieve the same feature using module builder?

Hey there

Ahhh, sorry, I think I misunderstood originally

So is it that you want BOTH the Original Contacts Module and a new Custom Module to use the same Database Table?

(So the data from the “Contacts” table is seen in two modules?)

If so, I don’t believe that’s possible in Module Builder

The Database table is generated upon Deploying the Custom Package/Module, using the Name of the Custom Module as the Table Name

I don’t think there are any options to specify a table for the Custom Module to use, i’m afraid

You may be able to achieve this through custom-work, but I imagine it’d be rather difficult as various associations may need to be changed across the Codebase
(Depending on Any Relationships to other modules)

However, a good place to start looking is likely the Vardefs for the Custom Module
(ie: modules/[custom module name]/vardefs.php)

As well as the file in the location:
modules/[custom module name]/[custom module name].php

As these build the core of the module, including the DB table used as well as field definitions

1 Like