AnsweredAssumed Answered

Copy fields from Opportunities to custom module

Question asked by CMiller00 CMiller00 on May 13, 2015
Latest reply on May 16, 2015 by CMiller00 CMiller00
My company is using SugarCRM Professional 7.5.2 OnDemand. I've been sucessful in creating a new record in our custom "Awarded Opportunities" with the name field filled in via a string in the code. I am having trouble when I attemp to use the hook to copy information from a field in the Opportunities module. I've tried using both $bean and $focus (not sure what the difference is). My code is below. Any suggestions? 



<?php
    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
   
    class awarded_class
    {
        function moveOpportunity_method($focus, $event, $arguments)
        {
   if ($focus->sales_stage == 'Closed Won')
   {
  
    $award = new CO_Awarded_Opportuities();
    $award->name = $focus opportunity_name;
    $award->save();
  
   
   }    
  }
    }

?>

I know that opportuities is the incorrect spelling, but that is what my custom module name is also. The label is spelled correctly :).

Thanks

Outcomes