Find the save registry function

Saludos.
Hi.
I made two modules with Module Builder in SuiteCRM 7.8.2

The modules are related (A->B ) ‘One to Many’

When i save a new registry from ‘B’ module i need the value ofa field that sum to a field of the registry related from module ‘A’

I have no trouble with the logic and the way to get the related bean, i just cannot find the function that save the data of the registry as i plan to do the sum in that function.

Where can i find that funcion?

Thanks.

I think you mean “record” instead of “registry”…

Are you looking for bean->save() ?

Maybe you can share your code so we can see what’s going on better.

Hi pgr.

I’m no looking for ‘$bean->save()’, just the function that fires the event from that button.

I began to code a logic hook, i pretend that works when i save that registry


<?php
  $hook_version = 1;
  $hook_array = Array();

  $hook_array['before_save'] = Array();
  $hook_array['before_save'][] = Array(
    50,
    'DataUpdater',
    'custom/modules/<my_module/DataUpdater.php',
    'DataUpdater',
    'updateData'
  );

In DataUpdater.php i have the code:


<?php
class DataUpdater{
  function updataData($bean, $event, $arguments){
    $newData = $bean->data_field;

    $relatedBean = $bean->get_linked_beans(
      'name_field_related',
      'module_related',
      array(),
      0,
      1,
      false
    );
    updateDataOtherModule($relatedBean, $data)
  }

  function updateDataOtherModule($relatedBean,$data){
     ....
     $relatedBean->data = relatedBean->data + $data;
     $relatedBean->save();
  }
}

So, i don’t know if the key ‘before_save’ is the appropiate to the event of the button.

So, with the class DataUpdater.php do i need to execute ‘$bean->save’?

Thanks so much for help

Oh, I see. I’m not an expert in customizations, but I think normally this kind of thing goes in the “after_save” hook. So, when the user saves a record, after the database update is complete, you get a chance to go into a related record and change something accordingly.

Make sure you don’t create infinite loops if you program two after_save hooks, one on each side…

Do you have Jim Mackin’s eBook “SuiteCRM for Developers”?

Thanks for aclaration.

Yes, i have the book,i am following that to this customization.

Thanks again