Make "Contact Search" return only contacts related to that account

In “Accounts” module, I created a relate field named “Person of Contact” to specify which contact is the authorized one to be communicated with, this field searches all accounts in the system. I need it to have a default search value for the account I am editing, so the search results are short-listed to the contacts that relates to that account only.

What I thought of:
1- The search in convert lead behaves like this, but I did not get where the logic is located.
2- The search contact popup has to pass account name in this part of its link field_to_name[]=name, I could not find where to edit it.

Hi sarahmdht, you can search for this argument:

How to add initial_filter for popup with a value taken from another field
(autopopulate a popup filter)

Example:

In SuiteCRM , a relate field can be added to EditView form using a popup from where you can select the desired entry.

In popup, you also have possibility to perform a search to filter the results from related module.

The nice part is that you can automatically send a filtering parameter using “initial_filter” from editviewdefs.php definition. So, for related field you have to add those lines:

'displayParams' => array(
     'initial_filter' => "&account_name_advanced=John%20Doe",
)
1 Like

It worked finally and simply.

I wanted it to work dynamically so I added it as

'displayParams' => array(
  		  'initial_filter' => '&account_name_advanced={$fields.name.value}',
			),

Thanks

1 Like