Sugar OnDemand 9.1.0 Professional
When an opportunity reaches a sales stage of Closed Won, we create an account record in the Accounts module. The below works as intended in that respect, but I want to ensure that all data from the Opportunity record is copied over to the new account record and then deletes the opportunity record. Can you help me achieve this?
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
function after_save_method($bean, $event, $arguments)
//check if a fields value has changed
if(isset($arguments['dataChanges']['sales_stage']) && $bean->sales_stage=='Closed Won')
$newAcc = BeanFactory::newBean('Accounts');
$newAcc->name = $bean->name;