Update field with data from related module

I have added a custom module related to opportunities. I would like to have the Name of the records in that module be the same as the name of the related record in Opportunities. Can someone suggest the best way to do this? I have tried to do it through logic hooks, but have been unsuccessful so far. Are logic hooks the best mechanism?

Thanks in advance.

I would certainly use a logic hook for this

use a before_save logic hook

get the opportunity name then set the name in your custom module

1 Like

Thanks for the help. Do you think it’s easiest to then call a SQL statement to update the field? If so, are the only two tables needed the Opportunities one and the custom module’s table with an inner join?

Do it as a before save of your custom module

I would retrieve the opportunity to get the name

then set the new module record name

$bean->name = $opp->name;

Hi,

The easiest and most appropriate way to do this, is the before save logic_hook.

I appreciate mikesolomon, please find some what detailed solution.

$opportunity = new Opportunit();

$opportunity->retrieve('ID OF OPPORTUNITY');

$bean->name = $opportunity->name; // Here bean will be your custom module. 

Hope this helps… :slight_smile:

1 Like