Clone Entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    Clone Entity

    Hi,

    i need to clone a entity (i know is bad) .. but i just need clone all attribute :
    sample

    entityA {
    name => "blabla",
    assignedUser => "bb",
    teams => ['teamA' , 'teamB'],
    accountId => '123'

    }

    so i need :

    newEntity = clone entityA

    newEntity-set([
    'name' => 'newName'
    'accountId' => '222'
    ]).
    saveEntity->(newEntity).

    it's possible ? i change only 2 attribute.

    Resume : i will not write by hand all attribute.




    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • telecastg
    Active Community Member
    • Jun 2018
    • 907

    #2
    Hello item

    Unfortunately the only way that I think you can clone an entity (actually a new database table) is to follow eymen-elkum tutorial.

    You will basically need to reproduce everything that the entity manager does when you create a new entity.

    Best Regards
    Last edited by telecastg; 11-26-2022, 08:42 PM.

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #3
      Hello telecastg,
      no, it's not clone a entity like in entityManager, it's more clone a "record".

      for me maybe solution is : https://www.doctrine-project.org/pro...-or-clone.html

      in healthcare, all entity, record, relation must be "isolated" to Patient. (law)
      so sometime, we have same entity, record.. we just need to "clone" one, change some attribute and save. (it's for law :s )

      regards
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        Could you use create a "template" record with just the basic or common to all attributes and links defined and then use the "Duplicate" dropdown option in the detail view to create a clone ?
        Last edited by telecastg; 11-27-2022, 07:04 AM.
    • item
      Active Community Member
      • Mar 2017
      • 1476

      #4
      Hi telecastg,
      why i have not thinking that



      thanks man
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        My pleasure
    Working...