Announcement

Collapse
No announcement yet.

Workflow Wont Trigger

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Workflow Wont Trigger

    Hi All,

    I have a module with a "many to many" relationship field.
    I would like to run a service when new record is linked to this entity.
    I have used the "After record updated" trigger type.
    When I update any field, the workflow runs well but when I link a new record of the many to many relationship, it does not trigger the workflow.
    How is this supposed to be done please?

    Thank you in advance

  • #2
    Hello,

    not really study this case but you can do so :
    in hook (need coding)
    afterRelate,
    afterUnrelate



    just save entity... so workflow certainly trigger.


    Maybe a feature request if not exist

    Comment


    • #3
      item it worked like a charm
      Thanks for the clue.

      For those who may be stuck in the same situation, here is my working code. You can customize as you wish.
      namespace Espo\Custom\Hooks\Resume;

      use Espo\ORM\Entity;

      use Espo\Core\{
      ORM\EntityManager,
      };

      class ResumeJobCategory extends \Espo\Core\Hooks\Base {
      protected $entityManager;

      public function __construct(EntityManager $entityManager) {
      $this->entityManager = $entityManager;
      }

      public function afterRelate(Entity $entity) {
      $entity->set("lastJobCatRelateTime", time());
      $this->entityManager->saveEntity($entity);
      }

      public function afterUnrelate(Entity $entity) {
      $entity->set("lastJobCatRelateTime", time());
      $this->entityManager->saveEntity($entity);
      }
      }

      Comment

      Working...
      X