How to add "Add to target list" option to custom module

I have created a module based on the Contact one, adding more fields. How can I add the entities of this custom module to target lists in the same way you can add Contacts to target lists? (
I would like to add the same option to the “Bulk Action” dropdown in the custom module table (

Thanks in advance.

You have to create a relationship between your custom module and the TargetList module.
Please note that the TargetLists module used to be called ProspectLists so, when you create the relationship you should look for ProspectLists if TargetLists is not available.
I believe that you are looking to create a Many to Many relationship, but it really depends on what you want to achieve.

Hi Amariussi,

Thank you for replying.

I cannot find either entries in my list.

What can I do?

I really need to be able to add contact to target list.


If the module is not available you should be able to do it programmatically but you have to search the web to find out how to add a relationship via coding. It shouldn’t be difficult.
In case you try you should back everything up before. Better if you try first on a fresh install.

I don’t know why you need this functionality. If you want to use it to send email campaigns you will have to write some code.
In that case have a look at the following link (which may contain also the directions on how to create the relationship).

Another solution would be that, instead of using a search you could use a report and then try to add the report result to a target list (I don’t know if this works).

1 Like

Yes, it is exactly for that. I think your link may help me to do it.

Many thanks.



I have managed to add Target List to studio in order to create the relationship (create a file studio.php inside custom/modules/ProspectLists/metadata) So I created the relationship TARGET LIST many to many ACCOUNT (custom module) and TARGET LIST many to many CONTACTS (custom module).

This way, I cannot see the buttons ADD TO TARGET LIST and ADD CONTACTS TO TARGET LIST in bulk actions either in accounts or contacts.

Previously I’ve created the relationships ACCOUNT (custom module) many to many TARGET LIST and CONTACTS (custom module) many to many TARGET LIST. This way, I could se the subpanels in Target list but when I added contacts it keeps TOTAL ENTRIES 0.

What do you suggest?

Thank you so much.


I have also created a report and then try to add the report result to a target list but it says TOTAL ENTRIES 0

I am not sure I understand precisely what you have done.

Can you explain more in detail please?

If I were you I wouldn’t use the names accounts and contacts for your custom modules because you may end up confusing things.

How did you create the custom modules? What base modules have you used?

Since you want to clone Accounts and Contacts, could you explain a little what you are trying to achieve? Why not use the standard Accounts and Contacts modules and add the necessary information and customisations to these modules to achieve your goals? Probably it’s easier and more reliable!

Thank you very much Amariussi for your help.

I explain myself from the beginning.

My business deals with two different kind of contacts, and each one has specific data that must be provided. Apart of that, I need to send campaigns to those contacts.

Posible Solution A:
I could create a field with an enumeration in the native module Contacts, in which you choose the type of contact you are going to add, and depending on which type you select, force to fill some fields or anothers (I dont know if this can be done, or how).

Posible Solution B:
Create a duplicate of the module Contacts, rename them, so I would have two modules with the same functionality, and depending on which type of person is, add him to one module or another.

What’s your opinion on these approaches? Are there any other alternatives?
Thanks in advance. Really appreciate your help.

I think that the best and easiest way to achieve your objective is Solution A (use the standard Contacts and Accounts).

First step:
create the necessary field to identify the two types

Second step:
create the fields that are unique to each type. When doing this try to think if it is possible to use the same fields. For example you could use a Dropdown to select the type and one or more dynamic dropdowns connected to the type to select other attributes.

Third step (if necessary):
write some custom code (there are plenty of examples around: I will look for something too) that, depending on the type hides or unhides unwanted/wanted fields. This code may empty the values of the unwanted fields as well (although this latter part can also be done with a workflow, so you avoid writing code).

Additionally you have to cope with compulsory fields (for this, depending on your requirement, you may use standard functionality or will have to write custom code)

For example, we need to make 10 fields always mandatory (Name, email, etc) and 5 fields mandatory if you select type A (15 fields in total), or another 7 different mandatory fields if you have selected type B (17 fields in total)

If you could find any example or point me towards the right direction I can try to write the code, I have programming skills but I have never made any customization to SuiteCRM yet.

Adding javascript to make certain fields compulsory:
There are various ways to do it. One way is explained here:

Alternatively you can use a logic hooc that echoes some javascript upon loading the form
Look here:

Using the same techinque you can also add some javascript that hides/unhides certain fields when type is A or B (I would also empty the values when you change type, or you may run a workflow that does it - I am thinking in case someone starts with type A and then switches to B after having filled some fields that pertain only to A)

It shouldn’t be too difficult, provided you know enough javascript.

In order to find the names of the fields or their ids, you should first create the form then use the browser to view the source and find the names of the fields to manipulate.

I hope this puts you in the right direction.

Please post back when you are done and if it works, please share your solution with everyone.

Here is another example;

You will have to do something similar in the Detail view to hide unwanted fields, depending on the type.

Thank you so much. You have been amazing.

I will try it and share the solution with everyone.

Have a good weekend.