SugarCRM customization tutorial – Creating custom module

/, SugarCRM, SuiteCRM/SugarCRM customization tutorial – Creating custom module
  • SugarCRM Customization Tutorial Banner Image Veon

SugarCRM customization tutorial – Creating custom module

SugarCRM by default has build in modules so, one can fulfill their business requirement by using the modules like Leads, Contacts, Accounts, Activities(Notes, Emails, Meetings, Calls), Opportunities, Cases  and more. However, some times business need  cannot be fulfilled by the built-in modules. In these cases we need to customize the platform and create a custom module. This article is meant to be a SugarCRM customization tutorial on creation of new module. The platform provides a  tool called ‘Module Builder’ to build a custom module which can be found in admin section. With the help of module builder, one can only create the module without any logic hooks or business logic. So to build components at one place, we need to develop the package which can be installed.



So before proceeding ahead one need to have a basic knowledge of the manifest package in SugarCRM. A manifest file should save with the name “manifest.php”.  $manifest variable that defines the basic properties of the module loadable package. So there are various properties   which we need to include while creating the manifest file.

  • acceptable_sugar_versions – defines in which version of SugarCRM you are going to install your package sugar version. Here we have ‘exact_matches’ and ‘regex_matches’.
  • acceptable_sugar_flavors – It defines the 4 flavors community, professional, enterprise editions. Adding these all edition you can installed your package any of SugarCRM edition.
  • name – Defines the name of the package.
  • key– Defines the unique identifier for package.
  • description – Defines the description of the package.
  • is_uninstallable – Defines whether package can be uninstalled or not. Here you need to give values in ‘true’ or ‘false’. True defines you can uninstall your package you want and false will disable the uninstall feature.
  • type– you can give values like module ,langpack, theme , patch.
  • version – Defines the version of the package. It can be “1.0”, “1.1”.

These properties are important while developing the manifest file. They should be defined in $manifest array.

The attributes which we need to define in $installdefs array variable those are.

copy – An array defines where the created files should be copied when you are installing the package. A source and destination path must be specified for the each file.

In the copy variable you can define the language ,layoutdefs, vardefs, logic_hookscustom_fields creation.

Module Creation

First create a folder with name <PackageName>. Follow the steps of creating the package.

Create the manifest.php in the same folder as Package, give properties name, version, id in $manifest array variable and from and to in copy index as per your requirement. This manifest file is used for the package. Example of the manifest file

Package Name

Here “Veon” is the Package Name.

Here we can see the files LICENSE and README file. Create these text files as you required.

Then create the folders named ‘modules, ‘language’ and file manifest.php (this file for module) inside the Veon. Example of the manifest file for the module –

Create a folder inside the modules with the same name which you have given in ‘from’ and ‘to’ in the copy array. Save folder name with “Sales” name.

Ex –  Veon/modules/Sales

Inside the Sales folder we need to create the folders metadata, Dashlets and language along with three php files (relationships.php, vardefs.php, config.php).

Ex – Veon /modules/Sales/metadata

Ex – Veon /modules/Sales/language

Ex – Veon /modules/Sales/Dashlets

Package PHP files

You can see folders and php file which we go through one by one.

Config.php

Here we can provide basic properties for the module like Label Name, Importable, etc.

relationships.php

If you want to make relationship with your module to some other module then you can write your code here or else can be empty php file.

Vardefs.php

If you want to create the fields then you can create in this file.  But here custom fields have not created.

In this file, we can create the fields that you require with this module.

metadata

In this folder you need to define your entire view files like editviewdefs.php, listviewdefs.php, detailviewdefs.php and some other files. So let’s start to create these file.

editviewdefs.php –

In this file you need to define the edit view of your module. ‘name’, ‘assigned_user_name’, ‘description’ are fields that are created by default in the SugarCRM for all the modules

detailviewdefs.php  –

In this file you need to define the detail view of your module. For this code will be

listviewdefs.php  –

In this file you need to define the list view of your module.

searchdefs.php- 

In this file you need to define the search view of your module. For this code will be.

SearchFields.php –  

In this file you need to define the fields for search view.

dashletviewdefs.php-

In this file you need to define the dashlets view of your module. For this code will be.

popupdefs.php-.

It will define the search from and list view in popups.

quickcreatedefs.php-

In subpanels you can create the record. This view definition you need to define in metadata.

metafiles.php-

In this file you need to define the location of metadata definition files EditView, DetailView, List View, and Popup code which will check the presence of these files.

Create a folder inside the metadata folder named “subpanels”. Inside this folder create a file default.php

EX – Veon\modules\Sales\metadata\subpanels\default.php

Create a folder inside the Sales(<Module>) folder named “Dashlets”. In this folder you need to create a folder with name “VN_SalesDashlet”.

Note*-

  • “VN” is the key for the package.
  • “Sales” is the module name

EX-   Veon\modules\Sales\Dashlets\VN_SalesDashlet

Inside this folder you need to create two files with names “VN_SalesDashlet.meta.php” and “VN_SalesDashlet.php”

Sample Code –

VN_SalesDashlet.meta.php

VN_SalesDashlet.php

Now you need to create the language folder inside the modules. This language file defines the name of your field. You need to create the en_us.lang.php file.

EX- Veon\modules\Sales\modules\Sales\language

Fields or label whatever you will see in SugarCRM those are defined here.

Now one more folder to be created in Sales folder with name ‘language’. Inside this language you need to create the application folder for creating the en_us.lang.php.

EX – Veon\language\application

Now you need to select all folders and files in root and compressed it to zip file.

compressed zip file

Now you have created the zip file so you can installed it SugarCRM .

Installation in SugarCRM

First open your Instance. In right side you will get Administrator, click on Admin. In the Developer Tools you will find Module Loader.

Installation in SuiteCRM

Click on the Module loader. Click the “Choose File” button in module upload panel.

Choose File module upload panel

After choosing the file it will look like this. Click on the Upload button for Uploading Package.

After uploading your package, it will show in the Uploaded Package Panel.

Uploaded Package Panel

Now click on the install Button for installing package. Completion of installation it will look like this.

installed successfully

So the package is installed successfully.

Now you will get your package in Module Builder you need to deploy your package.

Module Builder package list

Here you can see package “Veon” has successfully installed.  Click on the Veon and deploy it.  After Deployed Package Do Repair. If we don’t do repair and rebuilt it may possible that we cannot see our code change effect. So it is also recommended to do cache clear.

After repairing and rebuilt you will find Sales module in modules list. If you are not finding then go to the Admin > Display Modules and Subpanels. There you will get Display Module and Hidden Module if your module is in hidden module then drag it in display panel and save it.

Spread the Wisdom
By |2018-03-28T21:16:00+00:00March 23rd, 2018|CRM, SugarCRM, SuiteCRM|0 Comments

About the Author:

Veon brings best in consulting and integration solutions on Salesforce, SugarCRM, and SAP. It is an innovative company which deals best of the breed solution using integration solutions on the above platforms. making small and medium enterprise become smarter.