AfterSave Event Hook

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • DevMostafa
    replied
    Thanks Tarasm for your help

    Leave a comment:


  • tarasm
    replied
    Here is documentation on github https://github.com/espocrm/documenta...er/development.

    Leave a comment:


  • DevMostafa
    commented on 's reply
    I did manage to access this url

    but the parent url didn't open, So I think it is a private (not public) url.
    I want to ask you if there's a full Development documentation to browse it.
    I made this code and I think it runs now successfully, but I'm enhancing now the trigger event time.

    $recordId = $entity->get('id');
    $entityManager = $this->getEntityManager();
    $workLog = $entityManager->getRepository('WorkLog')->where(array(
    'id' => $recordId,
    ))->findOne();

    $text = null;
    $accountOpening = $entityManager->getRepository('WorkLog')->
    findRelated($workLog, 'accountOpening');

    if(isset($accountOpening)){
    for($i = 0 ; $i< count($accountOpening) ; $i++){
    $text.= ",".$accountOpening[$i]->id;
    }
    }
    $entity->set('firstName', $text );

  • tarasm
    replied
    These might help you:
    https://www.espocrm.com/documentatio...lopment/hooks/

    Leave a comment:


  • DevMostafa
    started a topic AfterSave Event Hook

    AfterSave Event Hook

    I want to make a Hook to handle "afterSave" event for getting the attached "Worklogs" entity [as comments] attached to another "AccountOpening" entity. I made this code but It didn't run:

    $entityManager = $this->getEntityManager();
    $account = getEntity('Account', $accountId);
    $record = $entity->get('id');
    $parentAccountOpening = $entity->get('id');
    $relatedAccountOpening = $entity->get('accountOpeningsIds');

    $list = $entityManager->getRepository('AccountOpening')->findRelated($entity, 'workLogs');
    $listA = $list->toArray();
    for($i = 0 ; $i < count($listA) ; $i++){
    $entity->set('description' ,$listA[$i]);
    }


    and tried another way but also not successful:

    $accountOpening =$entityManager->getRepository('WorkLog')->find();
    $workLogs = $entityManager->getRepository('AccountOpening')->findRelated($entity, 'workLogs');
    $entity->set('description', $workLogs->id);
Working...