AnsweredAssumed Answered

How to update a field in an after_save logic hook?

Question asked by Jaume Albaigès on Nov 25, 2014
Latest reply on Oct 21, 2019 by M Gupta
Hello all,

I have created a custom field to hold an autoincrement value for each record in the module. This works ok.

I would like to use this number as a part of the name of the record. So, I have created a logic_hook based on the after_save event.

Unfortunately, it seems that $bean data is not available when after_save-ing.

It I test the logic_hook in before_save event, the code works ok and Name field is properly updated. However I can't use the code in before_save because it only would work when editing records not when creating them, because the logic hook would be fired before setting the autoincrement value.

Any ideas?

Here is my code, so simple. I'm on SugarCRM CE 6.5.11.
class my_class{
  public function my_function(&$bean, $event, $arguments){
    $bean->name = $bean->my_autoincrement_field_c;