0

I want to use new inserted id for another field after insert.

I want to use it for my document ID, example when new record inserted, the auto increase id will have a prefix and follow with the auto increase id, it will stored in the account custom table (account_cstm) with a new field call "document_id_c".

Example the auto increase id is 18, the data will be stored in document_id_c is "DOC18".

I tried smtg in logic hook:

$bean->account_number_c = 'DOC'.$bean->account_number;
$bean->save();

But it seems like not working.

Another problem is, i need to show immediately after record has been saved.

Need some advice. Thanks!!

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Jack
  • 377
  • 5
  • 19

1 Answers1

0

First use $bean->id = create_guid(); after that create custom id accordingly and assigned in your field and call $bean->save();

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
  • If you create the ID yourself you will also need to set $bean->new_with_id = true or it will think you are updating and existing record. – MartinTawse Jan 10 '14 at 10:20