Logic hook vs JS function to autofill a field

Hi everyone, I am trying to achieve a custom function but I don’t know if it can be done.

I’ve created a field name “Area” and every Company (whose relationship with project is Company 1 - N Project) is associated with one Area (1 to 1). Every time the user creates a Project and fills the Area field, in Edit / Create View, I want the Company field to autocomplete.

I have thought in a logic hook, but that wouldn’t update the content in real time, so my other option is to invoke a JS function.

Any idea on how to approach this? Thank you in advance!

Just to clarify… “Area” field is a dropdown, textbox, or ?
According to all that you wrote for each Company, you are going to have one Area , am I right?

“Area” is a dropdown.
And yes, one Company has one and only one Area. And each Area corresponds with just one Company.

So when you reach 500 companies(assuming these are accounts) you are going to have 500 records in a dropdown?
Why not to create a simple module, instead of dropdown, and do a 1-to-1 relationship with companies?

Yes, they are Accounts, and yes, it’s one company per area, there can’t be two.
If I create a module instead of a dropdown, the autofill will be easier?

I don’t know if it will be easier, but in both cases you have to implement the autofill with javascript.
The point of my previous post was that having 500 records in a dropdown is too much.
Consider that these records are saved in a php file and not in the database.

1 Like

if I have understand… it’s easy without code.

1 Company => relate field to 1 Area Module. (Module as erevodifosin say, 500 is not possible by dropdown )

Then, a simple workflow … who get “area” from company and put in Project. (Projet too relate field to Area Module)

On save, always… scheduled…


Now it has slightly changed. A company can have many Areas, but inside the Opportunity, they would only work in one specific area. This could be achieved if SuiteCRM had the field type “Dynamic Related Field”.

That way, with the relationship you proposed, I could choose an Area, and then in the “Child” Related Field, choose a Company within the Area.

Is there any way I can do that with the Studio? If not, how would I code this? Thank you so much.


I ended up choosing something like erevodifosin proposed:

I created a module so that I could manage the relationships with the areas, but at the same time, this module has a 1-1 relationship with companies and has a dropdown, so that the client can see it is related to an area and a company.

Thank you!