Creating a new field for targets and relationship to leads and contacts

Using SuiteCRM 7.8.31. I created a custom field for targets and would like to have the same field for leads and contacts. It works great for targets and I have used it successfully. As a target gets converted to a lead I would like that field and its value to follow the lead, the same goes for when a lead is converted into a contact.

Looking at Studio I found that the newly created field for targets is available for leads as well but not for contacts. Does this mean that when a target with info in this new field is converted into a lead the value of this new field is available for the lead and subsequently, if the lead is converted to a contact, it will be available here as well? I can see in MySQL that this new target field is not only in prospects_cstm but also leads_cstm but not in contacts_cstm.

Alternatively, do I need to the corresponding new field for leads and targets and somehow get the lead to pick up the information from the target when converted etc.?

If the fields have the same name (internally) they will get carried across in Conversions (any conversion, also to Contacts).

Why don’t you have the field in Contacts, if you want it there?

I began by creating the field for Targets with the intent to later also use it for Leads and Contacts. So far, data has been created for most of the Targets but nothing done yet for Leads (nor Contacts).

As I mentioned, I can see that this custom field created for Targets - and therefore exists in prospects_cstm - also exists in leads_cstm but does not (yet?) exist in contacts_cstm.

Should I understand this to mean that as soon as I begin using it for Leads, this custom field will automatically show up in contacts_cstm as well?

If the field exists in Leads, it’s because you created it, even if perhaps you don’t remember it. So you can go ahead and create it also in Contacts.

SuiteCRM does not create fields automatically for conversions. It only copies the data from pre-existing custom fields onto pre-existing custom fields in the destination table, if the fields have the exact same name internally.

You are probably right, I may have created it and forgot about it… Will work on this tomorrow again.

Thank you for your explanations.

1 Like

You were right.

By the way, when a custom field is deleted from within SuiteCRM, and the data is deleted, the column itself does not seem to be deleted from the corresponding contacts/leads/prospects_cstm table. Is that correct?

Would it be dangerous to actually delete that column from within MySQL itself once it has been deleted within SuiteCRM? Or might that cause problems within SuiteCRM?

When you do a Quick Repair and Rebuild, if you scroll down all the way to the bottom, does it show a button to run queries? If it’s there, press it.

No, there was no button after running the query. I did take a look at Accounts, Contacts, Leads and Targets and while in the first two the extraneous table columns were indeed deleted but not in Leads or Targets (ie prospects).

What could the reason be that those now-extraneous columns in those two tables were not deleted? Is there anything else I can try to get rid of them (not that they use any space, it’s just a matter of being neat and nice when looking at the MySQL tables directly…)?

My initial instinct is that you can delete the columns from the DB directly, but I don’t really advise it unless you have a way back in case something goes wrong.

By way back I mean full backups, or VM snapshots, or DB dumps, whatever.

What could go wrong is if there was still some left-over references to those columns, somewhere in the PHP code. In this case, you could also track it down and fix it; but you would have a broken system until you finished that job.

Understood. I may just leave it the way it is for now since the extra space used by these empty, unused columns is minimal. Don’t think I have used the columns in any php-code but I will look at this again some time in the future.

Thanks

1 Like