Over the decades many small to large business organizations started using CRM (on-premises / cloud) to maintain/develop/improve the relationship and interaction with their existing as well as potential customers. And every organization has its own custom business needs, to be implemented in the CRM, for effective system usage. These customizations may range from simple field creation, details validation of the record to complex integrations with other applications such as ERP, Accounting and Payment Gateway systems etc.
Custom fields and modules are commonly used in CRM to maintain custom data based on business needs. While you can create custom fields with standard data types sometimes there is a need to have “custom data type” like highlight text, auto-increment etc. to make it use at maximum potential. SugarCRM comes equipped to deliver to such custom business needs.
What is SugarCRM?
SugarCRM is one of the leading CRM platforms which gives you great scope to customize the platform according to the business need. Making the best out of it is a key constraint for any business. In this article, we are going to create a custom field type that highlights the text of the field with the selected colour in the studio at the time of field creation.
Steps to create custom field type in SugarCRM
- Below are the steps to create a custom field type
Creating the Javascript controller
- This controller is responsible to format the value and render the field while displaying the field in the view. Create a controller file in the below path.
- By default, all the fields extend the base template. Below is the sample code for the controller.
Define Handlebar templates
- Define the handlebar templates for the field to display in the views. Below are the three views for which handlebar templates need to be created.
- Record view
- Edit view
- List view
Record view
- This template defines the display of data in the record view. Below is the path to creating a record view template.
Edit view
- This template defines the display of data in the edit view. Below is the path to create an edit view template.
List view
- This template defines the display of data in the list view. Below is the path to creating a list view template.
- The field colors are passed to the above templates through the def array which is defined in our next step.
Add field type in studio
To display the new field type in the studio while creating the field, define a studio field template. Additional properties needed for the new custom type are mapped here. We will map ext1 and ext2 fields from the field_meta_data table to the backcolor and textcolor. Set the dbfield to varchar. Below is the path to define the studio field template.
Create form controller
- This controller handles the fields from studio->fields. Allows us to assign color values to the template. Below is the path to create the form controller.
Create Smarty Template
This template will define the fields studio edit view. This template includes coreTop.tpl and coreBottom.tpl. These 2 templates will have the common fields required for every field type. Below is the path to create a smarty template.
Register the field type
Once the studio template is defined, register the field as valid field type. In the below code we are overriding the save method by inheriting the base field type.
Create language files
- Define new field type in the field type list. This will allow you to select the new field type while creating a new field. Below is the path.
- Add the labels for the studio template in the below path
- Define the color dropdown list in the below path.
- Now navigate to admin -> repair -> Quick repair and rebuild.
Create new field with custom data type
- Once the Quick repair is completed. Navigate to the required module to create a new field. Below is the screenshot while selecting the data type.
- Provide the required details and select the colour codes for background and text colour.
- Save the field and navigate to the module record view. Below is the screenshot of the sample record.
In this way, custom data types can be created to meet the business needs like highlighting the important fields with colour and auto-increment fields giving you extended scope to store custom data.
Evaluating SugarCRM for your business – We can help
Reach out to us so that we can assess and plan a road-map for your CRM implementation. Let’s build a system, which you will use for years to come.
The post How to create Custom Field Type in SugarCRM first appeared on Veon Consulting.