Hi Guys,
I’m implementing a SuitCRM 7 instance in my company I have the requirement to implement a self generated opportunitu number, I created a custom field called opportunity_code_c TextField for this and also I created a PHP code for this and a Logic_hook.php but even after I Quick Rebuild and Repair it doesn’t seem to run the code so, what can I do to acheave this?
Is your code something like this?
custom/modules/Opportunities/logic_hooks.php
<?php
$hook_array = Array();
$hook_array['before_save'][] = Array(
1,
'Generate Opportunity Number',
'custom/modules/Opportunities/OpportunityNumberGenerator.php',
'OpportunityNumberGenerator',
'generateOpportunityNumber'
);
In your custom/modules/Opportunities
directory
<?php
class OpportunityNumberGenerator
{
public function generateOpportunityNumber($bean, $event, $arguments)
{
if (empty($bean->opportunity_code_c)) {
$prefix = 'OPP';
$timestamp = time();
$unique_number = $prefix . $timestamp;
$bean->opportunity_code_c = $unique_number;
}
}
}