Replicate the same view, but adding filters.

Hi everyone, this is my first post and since I started a project with suitecrm this forum has been a great help!

I have to create a custom module, let’s call it “Actions”.
Inside of this Actions module there’s a field “Section” with three possible values (“section1”, “section2” and “section3”).

Instead of showing the “Actions” view like every other module, I have to show three different views, one for the Actions with section “section1”, another for the “section2” and another one for the “section3” actions.

How could I approach this? Since it’s not filtering the list view generated when you generate the package, it’s more a copy-paste of the whole module, with different names, but pointing to the same entity in the DB but adding a “where” clause… And also the nav menu has to be modified… I know it sounds weird but any help will be appreciated! Thank you in advance!

I’m answering to myself with the approach I ended up choosing.

At the end I didn’t need to do exactly what I was asking in this post, but I had to do something similar with projects. I needed to show in another view only the projects that the current user was working on.1. I copied the project controller into the custom folder.

  1. In the controller, added a function called action_misproyectosview

[code]
function action_misproyectosview() {
$this->bean = new SOCustomProject();
parent::action_listview();
}

[/code]1. Created another class, SOCustomProject

class SOCustomProject extends Project {
	function get_list_view_data(){
	    global $current_user;
		$temp_array = parent::get_list_view_data(); //let it work as it does by default
		
		//now do our customization
		if(!($temp_array['ASSIGNED_USER_NAME'] == $current_user->name || 
		    ($current_user->empresa_adherida_c != "" && strpos($temp_array['EMPRESAS_C'], $current_user->empresa_adherida_c)) || 
		    ($current_user->colaborador_c != "" && strpos($temp_array['COLABORADORES_C'], $current_user->colaborador_c)) || 
		    ($current_user->cliente_c != "" && strpos($temp_array['CLIENTES_C'], $current_user->cliente_c)))) {
			//$temp_array['ASSIGNED_USER_NAME'] =  "<a href='index.php?module=Project&action=GrabCase&record=$this->id'>".SugarThemeRegistry::current()->getImage("uparrow_inline","title='".translate('LBL_GRAB_CASE','Cases')."' border='0'",null,null,'.gif',translate('LBL_GRAB_CASE','Cases'))."</a>";
			$temp_array = "";
		}
		
		return $temp_array;
	}
}	

By creating this, if you see a regular URL inside the CRM, we are “creating” an action, so we can call the same Module with the action we just created.
http://X.X.X.X/suite/index.php?module=Project&action=misproyectosview
And it will be processed by the class SOCustomProject.

I had another issue when rendering the table, as it will show the empty rows and had to change that with an

{if $rowData != ""}

in the ListViewGeneric.tpl inside the theme.

1 Like