auto filter relate field for current module or auto populate dropdown bog on page load.

I have been building and maintaining a SuiteCRM installation for our building firm. They have a site module that has one to many relationship to the house types. The house types work as templates for plots to be created. So when a plot is created on a site, all the detail from the house type is used to populate the plot module. This all works fine.
The problem is, now we are putting more and more sites on this, there could be a house type of say XYZ123 for site 1 and the same house type for site 2. However key information might be different between the two house types, that are named the same but related to different sites.

When creating a new plot, we are in site module, within the plot subpanel and you just need 2 bits of information, house type and plot number,

The problem is the house type field is a relate field and will show all house types on the system, so if the user typex ZYX123 it will show up all multiple options and not just the one related to this site.
Hope this all makes sense!

So is there a way that the relate field can be filtered automatically, so it will only show records related to the site the plot is being made in?
If not how could I use a logic hook to populate a drop down box? If so, any points on how, I know how to use logic hooks, it is populating the options to a drobdown box I am un sure of and which logic hook is best to use, I assume after_retrieve?

Any other suggestions on how this can be achieved are also welcome.

Any help would be very much appreciated.

Cheers

Version 7.10.7

Sugar Version 6.5.25 (Build 344)

There is a way to link Dropdowns to one another, so that what you select in the first filters the second:

https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/19487-how-to-create-an-associated-dropdown

You can also inject some Javascript into your view to do more complex logic.

1 Like