Autofill of matched data after relating an Entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brianpunzalan
    Active Community Member
    • Aug 2017
    • 62

    Autofill of matched data after relating an Entity

    Is there any triggers or hooks that could be triggered after selecting an Entity through selection? This is to let me autofill the data from the selected entity fields' to the current entity edit form.

    I was thinking that it could be the afterRelate() method or through the custom views.

    Please let me know the right path to do the functionality.

    Thank you!
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    Yes, there are hooks afterRelate and afterUnrelate.

    Comment

    • brianpunzalan
      Active Community Member
      • Aug 2017
      • 62

      #3
      Thank you for the response.

      Yes, I tried using afterRelate() method but its not executing the function.

      For example, I made a custom hook under /custom/Espo/Custom/Hooks/Project/Description.php

      This hook is not executing after I try to relate an Account to a Project entity.

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        application/Espo/Hooks/Common/Stream.php - there is an example
        you don't save modification

        and what is the relationship type?

        Comment

        • brianpunzalan
          Active Community Member
          • Aug 2017
          • 62

          #5
          Many Project, One Account.

          I want to map the data from an Account to the Project after selecting an Account through relation.

          The afterRelate() is only working on the Documents entity wherein I link documents since their relationship is Many Documents with One Project. (opposite of account)

          Is there a way I could do this on the other way around?

          Thank you!

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            Hello
            afetrSave hook for project. And check if ($entity->isFieldChanged('accountId'))

            Comment

            • brianpunzalan
              Active Community Member
              • Aug 2017
              • 62

              #7
              Thanks! This is what I am looking for.

              Thank you for the support.

              Comment

              Working...