Has anyone been able to add an initial filter on a subpanel? In Opportunities I want to limit the Contacts a user sees to only those linked to the selected Account. I already have the filter built and tested, just need to add it to a subpanel.
Has anyone been able to add an initial filter on a subpanel? In Opportunities I want to limit the Contacts a user sees to only those linked to the selected Account. I already have the filter built and tested, just need to add it to a subpanel.
You need to add the attributes relationship_file and relationship_class into target relationship and the define the relationship class accordingly, so you will be able to override the method 'buildSugarQueryRoleWhere' accordingly:
New attributes in the relationship
$dictionary["Account"]["relationships"]["account_cases"]["relationship_file"] = "custom/data/Relationships/CustomOne2MBeanRelationship.php"; $dictionary["Account"]["relationships"]["account_cases"]["relationship_class"] = "CustomOne2MBeanRelationship";
Changes in the relationship class, from the core relationship UserBasedRelationship
protected function buildSugarQueryRoleWhere($sugar_query, $table = "", $ignore_role_filter = false) { $sugar_query = parent::buildSugarQueryRoleWhere($sugar_query, $table, $ignore_role_filter); $sugar_query->join[$table]->on()->equals($table.'.'.$this->userField,$GLOBALS['current_user']->id); return $sugar_query; }
You need to add the attributes relationship_file and relationship_class into target relationship and the define the relationship class accordingly, so you will be able to override the method 'buildSugarQueryRoleWhere' accordingly:
New attributes in the relationship
$dictionary["Account"]["relationships"]["account_cases"]["relationship_file"] = "custom/data/Relationships/CustomOne2MBeanRelationship.php"; $dictionary["Account"]["relationships"]["account_cases"]["relationship_class"] = "CustomOne2MBeanRelationship";
Changes in the relationship class, from the core relationship UserBasedRelationship
protected function buildSugarQueryRoleWhere($sugar_query, $table = "", $ignore_role_filter = false) { $sugar_query = parent::buildSugarQueryRoleWhere($sugar_query, $table, $ignore_role_filter); $sugar_query->join[$table]->on()->equals($table.'.'.$this->userField,$GLOBALS['current_user']->id); return $sugar_query; }
I am sorry but I am not sure how your answer solves the problem of applying a dynamic filter to a subpanel. The relationship in question is a OOTB Many:Many relationship between Opportunites and Contacts.