i have vehicle details in my opportunity module. Opportunity and Contracts module have a relationship when i quick create contracts then i want vehicle details field automatically populate in contract module
pgr
26 August 2017 08:49
2
You can try doing that with a Workflow.
Or if you prefer a solution with code, Google for “after-save logic hook”.
I don’t know the exact details, you’ll have to search and try.
what is code of logic hook
i tried following code
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
class AutoPopulateFields {
function AutoPopulateFieldsLogicHooks(&$bean, $event, $arguments) {
if (!empty($bean->id) && empty($bean->fetched_row)) {
$GLOBALS['log']->info('AutoPopulateFields Logic Hook START');
//here we are going to verify fields
$sPrefix = $registration_no_c;
$sZeroPaddingString = '%05d';
$code = 'custom_' . $catagory;
//get settings from config table
$oConfig = new Administration();
$config = $oConfig->retrieveSettings('custom');
if (!array_key_exists($code, $config->settings)) {
//if no settings are saved then insert empty settings
$oConfig->saveSetting('custom', $catagory, 0);
//initiate counter
$sSettings = 0;
}
else {
//if settings exist fetch them
$sSettings = (!empty($config->settings[$code])) ? $config->settings[$code] : 0;
}
$sSettings++;
$oConfig->saveSetting('custom', $catagory, $sSettings);
$iCounter = sprintf($sZeroPaddingString, ($sSettings));
//here autopopulate
$bean->registration_no_c = $sPrefix;
$GLOBALS['log']->info('Autogenerate Logic Hook END');
}
}
}