Hi Everyone,
We need to update a parent entity (Quote) field after updating a child entity (Sales Order) field.
We created a custom repository SalesOrder.php:
Everything is working as expected, but the quote view is not updating (a browser refresh is needed in order to see the updated field).
We tried with hooks and workflows with the same result: view not updating.
Does anyone know how to trigger a view update of a parent entity after updating it from a child entity?
Thank you very much
We need to update a parent entity (Quote) field after updating a child entity (Sales Order) field.
We created a custom repository SalesOrder.php:
PHP Code:
<?php
namespace Espo\Custom\Repositories;
use Espo\ORM\Entity;
use \Espo\ORM\EntityManager;
class SalesOrder extends \Espo\Modules\Sales\Repositories\SalesOrder
{
protected function beforeSave(Entity $entity, array $options = [])
{
$quoteId = $entity->get('quoteId');
$entityManager = $this->getEntityManager();
$quote = $entityManager->getRepository('Quote')->get($quoteId);
$salesOrderCollection = $entityManager
->getRepository('Quote')
->findRelated($quote, 'salesOrders');
$quote->set('status', 'Accepted');
$entityManager->saveEntity($quote);
$this->processItemsAfterSave($entity, $options);
parent::afterSave($entity, $options);
}
}
Everything is working as expected, but the quote view is not updating (a browser refresh is needed in order to see the updated field).
We tried with hooks and workflows with the same result: view not updating.
Does anyone know how to trigger a view update of a parent entity after updating it from a child entity?
Thank you very much