My goal is to create a customisation which automatically applies a filter to the selection drawer that pops out when you click on the dropdown to select a related Contact in a custom Relate field in Calls.
The drawer must show only contacts which have the field account_id equal to the parent_id of the current call (which will always have an account as the parent).
For example, in this list, there should be only the contact called "Related Contact" with the custom filter automatically applied:
I have tried to make use of this page in the developer guide, but I haven't gotten anything to work yet. Neither the combination with the PHP filter and the JS filter nor just the JS filter.
Tried all kinds of ways to summon a drawer through browser's JS console with a custom filter created on the spot, just like in the examples at the bottom of the documentation page, but no success.
This is the code I tried in the JS console while viewing a call record with a parent account with that ID:
filter = new App.utils.FilterOptions()
.config({
'initial_filter': 'filterAccountContacts',
'filter_populate': {
'account_id': '7d85753a-a5fe-11e8-96df-0242e7a9117c'
}
})
.populateRelate(App.controller.context.get('model'))
.format();
App.drawer.open({
layout: 'selection-list',
context: {
module: 'Contacts',
filterOptions: filter,
parent: App.controller.context
}
})
It did open the drawer, but no filter was applied. But even if it did, opening the drawer this way and picking a record to relate would not populate anything in the current call record.
Is it necessary to extend the Relate field JS controller or any view controller? That would make it impossible for other customisation to extend it without overriding this customisation.
Can anyone please share some experience with this? What do I need to do to accomplish this?