Archive for September 2015

Apply initial filter in relate fields and relationship fields with quick(popup) search sugarcrm 7.x

In this article,I will be explaining how to apply initial filter in relationship fields including quick(popup) search in Sugarcrm7.x.Lets say we have accounts module(sugarcrm out of the box module),is having one-to-many relationship with accounts module,for the purpose of linking new records to old(parent) record.This is not sugar out of the box relationship,we have build this relationship.

In record view of accounts,When user is trying choose account for "parent account" relationship field,the system should display records except current record,(current account should not to be  available to select).Now we need to prevent user to choose same record as parent.

Lets go with example,We have one account named "Banque Lombard Odier & Cie SA" in accounts module.
This record should not link with same "Banque Lombard Odier & Cie SA".It can link with some other accounts.

To achieve this, we need to touch 3 files .There are 3 records in which starts with banq" in Accounts module.



Below is the Record view of  "Banque lombard odier & Cie SA" account.Here we are having parent account(relationship field) as  field.I have added filter defintion for this field.Now if you type "banq" in parent account relationship field,current record name will not be available to select  in quick(popup) search,open drawer and search in open drawer.(like below).



Lets dive into coding part,

Step 1 :

Creating filter template

First we need to create a filter template for accounts which will filter out only the accounts records except current account.
To do this we will create a new file in the following path.Let’s name this template as FilerAccountTemplate.

Create  file in below path

  /custom/Extension/modules/Accounts/Ext/clients/base/filters/basic/ FilerAccountTemplate.php

In this filter template,File name(FilerAccountTemplate) and id should be same(FilerAccountTemplate).

In this file we are defining filter definition in ("filter_definition") variable.Here i am using name is not equals in filter definition.We can use record id also instead of name.


Step 2:

Filter label

Now we need to give a display label for out filter template ,which we have created.

Create  file in below path

/custom/Extension/modules/Accounts/Ext/Language/ en_us.FilterAccountTemplate.php

Add file to below code

Step 3:

Controller 

              Now we need to pass this template as filter options into  the look up search when user try to select a account .For that we will create a new controller file for relate field and will extend it from parent controller.


Create  file in below path

/custom/modules/Accounts/clients/base/fields/relate/relate.js

Add below code


Note 
1. Accounts -module name
2. name- relationship field name
3. We are overriding getFilterOptions method.and we are defining our custom filter definition instead of default filter options.

This filter options is getting called  in opendrawer function also,So the same definition will be apply openselect drawer function as well.

here we are creating instance of filter options,and configuring with filter template name,filter label and passing current record name to filter definition.(this only will prevent system to not display current record).


The above our filter definition is getting apply in quick(popup) search,when user clicks "select more accounts" and in open drawer search .


That's it.

Inevitably Administration > Repair > Quick Repair and Rebuild  .

This is upgrade safe .



Customize change theme in sugarcrm 7.x


To override the default theme colors, a new variables.php file will need to be created.

Copy the /sugarcrm/styleguide/themes/clients/base/default/variables.php to /sugarcrm/custom/themes/clients/base/default/variables.php and edit the following three HEX color values.

By defaul Sugar crm theme looks like



By default sugar crm theme,  'BorderColor' => '#E61718', I am changing that to    'BorderColor' => '#0adf31',

Inevitably Administration > Repair > Quick Repair and Rebuild  .

Our customized theme looks like below.




Like BorderColor,we can change NavigationBar and PrimaryButton.

NavigationBar

By default in sugarcrm theme, 'NavigationBar' => '#282828', I am changing that to 'NavigationBar' => #000099'.

Inevitably Administration > Repair > Quick Repair and Rebuild  .


Our customized theme below.



PrimaryButton

By default in sugar theme 'PrimaryButton' => '#176de5', I am changing that to  'PrimaryButton' => '#000000'.
  
Inevitably Administration > Repair > Quick Repair and Rebuild  .

Our customized theme looks like below.




- Copyright © SugarCRM Blog - Ajay Kumar - Powered by Blogger - Designed by Ajay Kumar -