AnsweredAssumed Answered

filter_populate vs filter_relate with $contains

Question asked by Tom Noel on Jan 11, 2017
Latest reply on Jan 18, 2017 by Tevfik Tümer

I have a filter that is searching on a custom module using a selected account_id as a filter.  However I am getting different results based on if I used filter_populate vs filter_relate.  If I pass an account id via the filter_populate I receive the correct filter parameters in the request, but if I use filter_relate it adds [$in][] to the end of the filter parameter.

 

Here is my template:

<?php

$viewdefs['TA_PriceListParts']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterPriceListPartsTemplate',
    'name' => 'LBL_FILTER_PRICE_LIST_PARTS_TEMPLATE',
    'filter_definition' => array(
        array(
            'related_accounts_c' => array(
                '$contains' => ''
            ),
        ),
    ),
    'editable' => true,
    'is_template' => true,
);

 

 

array (
  'name' => 'ta_pricelistparts_revenuelineitems_1_name',
    'initial_filter' => 'filterPriceListPartsTemplate',
    'initial_filter_label' => 'LBL_FILTER_PRICE_LIST_PARTS_TEMPLATE',
    'filter_populate' => array(

    ),
    'filter_relate' => array(
        'account_id' => 'related_accounts_c',
    )
),

looks like this in the request:

  1. filter[0][$and][0][related_accounts_c][$contains][$in][]:
    5c2e05b8-c609-11e6-be45-06cd310e1a43
  2. filter[0][$and][1][name][$starts]:
    p
  3. fields:
    id,name
  4. max_num:
    5

 

However if I send the id directly to related_accounts_c using filter_populate (just doing this to test functionality) I get the correct parameters in the request

array (
  'name' => 'ta_pricelistparts_revenuelineitems_1_name',
    'initial_filter' => 'filterPriceListPartsTemplate',
    'initial_filter_label' => 'LBL_FILTER_PRICE_LIST_PARTS_TEMPLATE',
    'filter_populate' => array(
        'related_accounts_c' => '5c2e05b8-c609-11e6-be45-06cd310e1a43'
    ),
    'filter_relate' => array(
       
    )
),
  1. filter[0][$and][0][related_accounts_c][$contains]:
    5c2e05b8-c609-11e6-be45-06cd310e1a43
  2. filter[0][$and][1][name][$starts]:
    p
  3. fields:
    id,name
  4. max_num:
    5

 

What exactly am I doing wrong with the filter_relate that it is giving me the wrong filter parameters in the request?

Outcomes