I've implemented an 'afterSave' function in one of my custom Repositories but I cannot get a field to be 'set' - I see the value change initially before going back to 'None':
What am I doing wrong in this instance?
Code:
<?php namespace Espo\Custom\Repositories; use Espo\ORM\Entity; class SerialNumber extends \Espo\Core\Templates\Repositories\Base { protected function afterSave(Entity $entity, array $options = []) { parent::afterSave($entity, $options); // Get the linked part $part = $entity->get('part'); if ($part) { // Get the part number if ($part->has('partNumber')) { $partNumber = $part->get('partNumber'); $serialNumber = $entity->get('serialNumber'); $fullPartNumber = $partNumber . '.' . $serialNumber; $entity->set('name', $fullPartNumber); $GLOBALS['log']->warn('Number', [$fullPartNumber]); } } } }
Comment