Initial Filter on a subpanel "Link an Existing"

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.

Parents
  • 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;
        }
    

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply
  • 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;
        }
    

    André Lopes
    Lampada Global
    Skype: andre.lampada
Children