SugarCRM Popup Filter on Relate/Relationship field

SugarCRM Popup Filter on  Relate/Relationship field
SugarCRM Popup Filter on  Relate/Relationship field
SugarCRM Popup Filter on  Relate/Relationship field
SugarCRM Popup Filter on  Relate/Relationship field
SugarCRM Popup Filter on  Relate/Relationship field

Applying filter in SugarCRM on the pop-up view results of a relate/relationship field.

Why SugarCRM PopUp Filter?

While working in SugarCRM, many times we get the unnecessary records in relate field pop up view.

Sometimes, we have to filter the records manually as per our need.

It’s better to filter those records at the back-end as per system requirement and get the relevant records only.

So avoiding hectic job of manual searching. Let’s see how SugarCRM PopuP Filter is being implemented.

How ?

It’s simple, here is the answer.

For example, Add a filter in Account pop up view on

From the SugarCRM  Admin Panel, accessing the Studio or Module Builder, we can add the fields in the pop up the search.

Suppose we want to add a field Industry in search fields of Accounts module pop up view.

Step 1.   Go to the admin panel.

Step 2.  Go to the studio.

Step 3.  Select the module Accounts.

Step 4.  Select “Layouts” option.

Step 5.  Select “Pop-up view”.

Step 6.  Select “Popup Search”.

Step 7.  Drag the field “Industry” from the column Hidden and drop in “Default” column.

This is how anyone can add the fields in the pop up the search as per the requirements.

Going further now we want to use that field to filter the records in the pop view.

Only the records having Industry as “Consulting” should be listed in the pop-up view.

To perform this functionality at the back-end,  we have to work on the pop-up view of Accounts module.

As per the standard practice, we will do it in “Custom/modules/Accounts/views/” directory.

In views folder, you can see the file “view.popup.php”. If it is not there, create a PHP file with the same name.

If you create a new file add the code given below:

require_once (‘include/MVC/View/views/view.popup.php’);

class AccountsViewPopup extends ViewPopup

{

function CustomViewPopup()

{

parent::ViewPopup();

}

function display()

{

global $popupMeta, $mod_strings, $custom_filter_gcm;

parent::display();

}

}

Now to apply the filter we add some lines of code in the display function.

require_once (‘include/MVC/View/views/view.popup.php’);

class AccountsViewPopup extends ViewPopup
{

function CustomViewPopup()
{
parent::ViewPopup();
}

function display()
{
global $popupMeta, $mod_strings, $custom_filter_gcm;

/* We post the industry value as “Consulting” in an array. */

$_REQUEST[‘industry_advanced’] = array(‘Consulting’);

parent::display();
}
}

If we observe the pop view of Accounts module, we will get records of Industry “Consulting”.

And we are done.  It’s that simple.

If you have any such requirement and detail implementation help you can always contact us here.

Leave a Reply

Your email address will not be published. Required fields are marked *