How can I instantiate a entity in other entity controller?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krmn.msg
    Member
    • Jun 2016
    • 36

    How can I instantiate a entity in other entity controller?

    Hi!

    I want instantiate a entity in other diferent entity controller. For example, instantiate
    Opportunity entity in Account controller. How can I do it? Thanks!
  • yuri
    Member
    • Mar 2014
    • 8484

    #2
    Use $this->getEntityManager(). There is a documentation
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • krmn.msg
      Member
      • Jun 2016
      • 36

      #3
      I am using "$this->getEntityManager()->getRepository('Opportunity')->get('576c068c380779fb7')" and I'm sure that these object exists in database. But it gives a Error, that said it is null.
      I was seen the documentation and I don't get the solution.

      Sorry for the inconvenience

      Comment

      • tarasm
        Super Moderator
        • Mar 2014
        • 573

        #4
        Is this record ("576c068c380779fb7") is not deleted?
        Job Offers and Requests

        Comment

        • krmn.msg
          Member
          • Jun 2016
          • 36

          #5
          Of course, This is the id of the record Opportunity and it exists in my database, but this code return null. Idea??

          Comment

          • krmn.msg
            Member
            • Jun 2016
            • 36

            #6
            I did it

            Comment

            Working...