How to use 'Or' expression in custom filter for two different field in custom filter ?

Hi There,

I am looking to implement custom filters with 'OR' expression for two different field , As in sugar we can not use 'OR' expression for two different fields , it's working for same field. 

How can i implement it for two different fields ? 

As per below screenshot , I want to use these 2 filter  auto select on one of the dropdown selection , As per sugar default flow ,  For these 2 fields , 'AND' expression is being used , but i have to use 'OR' expression . 

Below is the code , i used for this : 

File : relate.js 

selectLocation: function () {
    var m03_work_product_name = this.model.get('m03_work_product_ii_inventory_item_1_name');
    console.log('m03_work_product_name', m03_work_product_name);
    var filterOptions = new app.utils.FilterOptions()
            .config({
                'initial_filter': 'FilterTestSystem',
                'initial_filter_label': 'Current Work Product Assignment',
                
                'filter_populate': {
                    'assigned_to_wp_c': m03_work_product_name,
                    'm03_work_product_id_c': ['4a529aae-5165-3149-6db7-5702c7b98a5e']
                },
                'filter_relate': {
                    'assigned_to_wp_c': m03_work_product_name,'m03_work_product_id_c': ['4a529aae-5165-3149-6db7-5702c7b98a5e'],
                },
            })
            .populateRelate(this.model)
            .format();
    //this custom code will effect for all relate fields in Enrollment module.But we need initial filter only for Test system relate field.
    filterOptions = (this.getSearchModule() == "ANML_Animals") ? filterOptions : this.getFilterOptions();
    app.drawer.open({
        layout: 'selection-list',
        context: {
            module: this.getSearchModule(),
            fields: this.getSearchFields(),
            filterOptions: filterOptions,
        }
    }, _.bind(this.setValue, this));
},

file : Filtertest.php : 

$viewdefs['ANML_Animals']['base']['filter']['basic']['filters'][] = array (
  'id' => 'FilterTestSystem',
  'name' => 'Current Work Product Assignment',
 
'filter_definition' => array(
  array(
    '$or' => array(
      'assigned_to_wp_c' => array(
        '$equals' => ''
      ),
      'm03_work_product_id_c' => array(
        '$in' => ''
      ),
    ),
  ),
),

  'editable' => true,
  'is_template' => true,
);

By using this ,  no filter is working , Below screen is showing : 

...

Parents Reply Children