I am working with three modules:
Account
Contacts
WContracts (custom)
On WContracts I have Account and Contact, both appear as a relate filed, both are the result of a 1-M relationship.
Accounts - Contacts is N-M
When an Account is selected and the user goes to choose the Contact, I want to restrict the Contacts available to only those on the Account.
I tried working through the example on the Developer Guide:
But I can't quite get it to work or understand the examples.
The hardcoded filter in the example is of no use in this scenario, I need the value to be dynamic.
And the dynamic filter example is for actual fields, but I don't have a Contact field on Account or an Account field on Contact, I have a relationship between Accounts and Contacts. If I used the Contacts popup as is the only think I have to go by is a non-db field with "ContactRole at Account" which contains the Account name and the custom ContactRole (a custom module where ContactRole has two relate fields: Contact and Account).
What I'm really trying to do is to have filtered collection by relationship... not by search field.
So maybe I should be looking at:
But it's still unclear to me how to use the relationship Accounts<->Contacts for the drawer filter.
Could I override the on click event on the Contacts Relate field to open a list of pre-filtered Contacts to select from instead of the standard select2 with the search option?
Because in that case I could use an API call to generate the collection:
url = app.api.buildURL('Accounts/'+account_id+'/link/accounts_contacts/')
and pass the resulting collection
contactsCollection = app.data.createBeanCollection( "Contacts", data.records);
to an app.drawer.open with layout selection-list and collection contactsCollection
thanks,
FrancescaS