AnsweredAssumed Answered

Filter to anything contained in a list of related records

Question asked by Steven Osborne on Nov 8, 2017

Hi,

I have the following scenario:

A meeting can be related to many accounts. When clicking the 'link existing record' button on the branch (custom module) subpanel of a meeting, I want it to automatically filter to only show branches that are related to an account that is in the list of accounts related to the meeting.

 

I have managed to filter the 'link existing record' panel using a panel top in order to filter to only show branches that are related to the account that is related to the meeting using a 'relate' field. This uses the following code: 

 

<?php

$viewdefs['BRH_Branch']['base']['view']['panel-top-for-meetings'] = array(
     'type' => 'panel-top',
     'template' => 'panel-top',
     'buttons' => array(
          array(
               'type' => 'actiondropdown',
               'name' => 'panel_dropdown',
               'css_class' => 'pull-right',
               'buttons' => array(
                    array(
                         'type' => 'sticky-rowaction',
                         'icon' => 'fa-plus',
                         'name' => 'create_button',
                         'label' => ' ',
                         'acl_action' => 'create',
                         'tooltip' => 'LBL_CREATE_BUTTON_LABEL',
                    ),
                    array(
                         'type' => 'link-action',
                         'name' => 'select_button',
                         'label' => 'LBL_ASSOC_RELATED_RECORD',
                         'filter_relate' => array(
                              'account_id_c' => 'brh_branch_accountsaccounts_ida'
                         ),
                    ),
               ),
          ),
     ),
);

However, this does not take into account meetings being related to multiple accounts.

 

The following api call achieves something similar by returning all branches that are related to an account whose id is contained in the specified list.

rest/v10/BRH_Branch?filter=[{"brh_branch_accountsaccounts_ida": {"$in":["0e089042-c3d3-11e7-ba43-c4b301d8ddd1","3289a320-c3d3-11e7-a15e-c4b301d8ddd1"]}}]

The only difference would be that the lis of account id's would be populated based on the accounts that the meeting is related to.

(it would also possibly be the opposite way round i.e. account_list: {$contains: brh_branch_accountsaccounts_ida})

 

Thanks for any help,

Steven

Outcomes