AnsweredAssumed Answered

My filter on a drawer(selection-list) does not work!

Question asked by Doddy Amijaya on Dec 14, 2017
Latest reply on Mar 1, 2018 by Raymond Tham

I have created a filter for the Products module, the filter itself is working. the only part that's not working is when I tried to load with dynamic values.

 

essentially what I want to do is to be able to do a lookup (this is not a relate field, it is a 1-1 relationship)

here is the structure:

Accounts has Products

and

Accounts has Software

when I am creating a Software record I want to be able to relate to a product that the Account (the parent of Software record) has.

 

FilterByAccountProduct.php


<?php

$viewdefs['Products']['base']['filter']['basic']['filters'][] = array(
'id' => 'FilterByAccountProd',
'name' => 'LBL_FILTER_BY_ACCOUNT',
'filter_definition' => array(
array(
'account_name' => array(
'$in' => array(),
)
)
),
'editable' => true,
'is_template' => true
);

 

root/custom/modules/Products/clients/base/fields/relate/relate.js


({
extendsFrom: 'RelateField',
initialize: function(options) {
this._super('initialize', [options]);

},
getDrawerOptions: function ()
{

console.log('set filter');

var filterOptions = new app.utils.FilterOptions()
.config({
'initial_filter': 'FilterByAccountProd',
'initial_filter_label': 'LBL_FILTER_BY_ACCOUNT',
'filter_populate': {
'account_name': [this.model.get('parent_id')],
}
})
.format();
},
openSelectDrawer: function() {
filterOptions = (this.getSearchModule() == "Products") ? filterOptions : this.getFilterOptions();
app.drawer.open({
layout: 'selection-list',
context: {
module: 'Products',
fields: this.getSearchFields(),
filterOptions: filterOptions,
}
}, _.bind(this.setValue, this));
},
})

 

when I do a lookup the filter wasn't selected. however if I do this in the browser console:

 

var filterOptions = new App.utils.FilterOptions()
.config({
'initial_filter': 'FilterByAccountProd',
'initial_filter_label': 'LBL_FILTER_BY_ACCOUNT',
'filter_populate': {
'account_name': ['96a965cb-97aa-8ecd-5b78-5705254f1074']
}
})
.format();

 

 

App.drawer.open({
layout: 'selection-list',
context: {
module: 'Products',
filterOptions: filterOptions,
parent: 'Software'
}
});

the drawer is filtered correctly.

 

anyone can help me? it's so frustrating. I feel like I am so very close yet so far away.

Alex Nassi

Francesca Shiekh

Angel Magana

Matt Marum

Outcomes