Copy vardefs from Leads to Contacts

Is there an easy way to copy Vardefs from Leads to Contacts. I have a project with like 100 custom fields and I don’t want to have to re-create them all in Contacts (they will follow on convert).

I tried copying all the contents of the Vardefs folder from Leads to Contacts and then replacing all the ‘Lead’ with ‘Contact’ in each one of the PHP files and then did a quick repair and rebuild. I was hoping that all the Vardefs would sync with the database and I wouldn’t have to enter them all again.

Anyone have an easy way of doing this? Or is it actually easier just to re-enter all 100 fields one by one?

did you make these fields in the studio?

I can’t help but comment - 100 fields is almost always a sign of bad database design. Data in 100 fields can surely be structured in some way, and put into sub-modules and be shown in subpanels.
I know customers sometimes ask this as a requirement “I have this contract here with 100 fields, put it on a module please”, but it’s our job to structure that, break it down, and then reap all the benefits of a good data design.


Sometimes there are more fields for the full use of the CRM functionality.

Hey @palach yes they were made in studio

Hey @pgr I know what your talking about. This isn’t a typical sales crm. Its a school where leads are applicants and contacts are students. The program is government funded so they have to collect and report on all kinds of demographic data for each student and in aggregate to qualify for the funding. Ie: normal stuff plus, gender id, incarceration status, pregnancy status, highest grade achieved, living arrangement, adoption status, ethnic identity, probation status, etc etc and it goes on and on. They have to report on things like ethnic identity of people applied vs. admitted and then there are certain demographic criteria that are a requirement for admission, so they have to show proof they’re collecting and administering the requirements, etc. etc. You know how governments are.

1 Like

I guess the answer is I have to enter them LOL. Feature Request studio custom field lead entry … “do you want to duplicate this field in the contact record?” Y/N.

Have you tried simply copying the PHP from one vardefs file to the other?

@pgr yes, that’s what I tried first and anything else I could find like labels, etc. I was really hoping the repair and rebuild when it syncs the database to vardefs that it would just create the DB tables and all would be good. I guess it doesn’t work that way.

I think it does work that way. You must be missing some small detail.

Go through this checklist to see if anything helps:

That’s what I tried, of course though I didn’t enter all those fields, I just copied from the LEADS module exactly what was there and just changed the module name from Lead to Contact. I’ll keep playing with it because this would be a huge time saver on future projects. (just spent all morning re-entering the 100 fields!)

That tip about needing to have at least one custom field already there might be all you need

I did try that too, I wanted to create one custom field just to see what files were created and see how it compared to what was created for the leads. I suspect it might have something to do with the last lines in the documentation (which are not present in the lead files) that specifies the custom table.

//required to create the field in the _cstm table
$dictionary['<module singular>']['fields']['example_c']['source'] = 'custom_fields';

That’s the only thing I did not try.

these fields are in the fields_meta_data table

Maybe this will help you:

Migrate Custom Fields
Migrates stupid custom fields created with Studio to “real” fields defined in the extended vardefs.

1 Like

Hi, like @palach wrote, the definitions are in the field_meta_data table. With the following query you can duplicate the entries for the Contacts module

insert into fields_meta_data 
select concat('Contacts', name), name, vname, comments, help, 'Contacts', type, len, required, default_value, date_modified, deleted, audited, massupdate, duplicate_merge, reportable, importable, ext1, ext2, ext3, ext4 
from fields_meta_data 
where custom_module='Leads' and name not like 'jjwg%';

You will then need to copy the field labels from
and merge them into

Further field configuration you might find in

You need to copy these files (skip those for jjwg_maps) to
and change the contents:




The following bash command makes the above modification for all files in the current directory, make backups and use with caution:

for i in *.php; do sed "s/'Lead'/'Contact'/" $i | sponge $i; done

Afterwards do a Admin / Repair / “Quick Repair and Rebuild”


@jansiero That’s awesome thank you. I had done all that except copying the database tables over. I was kind of assuming that the repair and rebuild would create the database tables from the vardefs. Wish I had known this yesterday LOL would have saved me like 5 hours! Thanks so much it will save me so much time on future projects.