Hello everyone,
Iām quite new to SuiteCRM and still learning the ropes, so please bear with me. Iām trying to customize the behavior of the āSM_Suppliersā module, which I created using Module Builder. My goal is to add custom validations when saving a record, specifically for the āvat_idā field.
I have created a controller.php
file in the following path: /volume/public/legacy/custom/modules/SM_Suppliers/controller.php
The contents of my controller.php
file are as follows:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class CustomSM_SuppliersController extends SugarController{
public function action_save(){
LoggerManager::getLogger()->error('SM_SUppliers --> This is an error message');
// Check if VAT ID is provided
if (empty($_REQUEST['vat_id'])) {
echo json_encode(['success' => false, 'message' => 'VAT ID is required.']);
exit();
}
$vatId = $_REQUEST['vat_id'];
// Query to check if VAT ID already exists
$bean = BeanFactory::newBean('SM_Suppliers');
$query = new SugarQuery();
$query->from($bean);
$query->select(['id']);
$query->where()->equals('vat_id', $vatId);
$results = $query->execute();
if (!empty($results)) {
echo json_encode(['success' => false, 'message' => 'VAT ID is already in use.']);
exit();
}
parent::action_save();
echo json_encode(['success' => true, 'message' => 'VAT ID is available.']);
}
}
?>
Problem:
Despite the controller.php
file being in the correct location and having performed a āRepair and Rebuildā in SuiteCRM, the custom code is not executing. I donāt see the error_log()
messages in the web server logs or the LoggerManager::getLogger()->error()
messages in suitecrm.log
.
Additional Information:
- SuiteCRM Version: Version 8.7.1
- Image Docker: https://hub.docker.com/r/bitnami/suitecrm
- **Created file in **:
custom/modules/SM_Suppliers/controller.php
-
File Permissions: 644
-
Directory Permissions: 755
I have tried:
- Checking the web server and SuiteCRM logs.
- Clearing the SuiteCRM and browser cache.
- Reviewing the file and directory permissions.
- Adding
error_log()
statements for debugging.
I would appreciate any assistance in identifying the cause of this issue.
Thanks in advance.