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.

Get started with SuiteCRM Services Now

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.