Announcement

Collapse
No announcement yet.

Copy one entity to another with all data

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

  • Copy one entity to another with all data

    Hello,

    How to copy all fields,relations and data of one entity to another entity by code?

    Just like we create duplicate records in record detailview?


    Please help.

    Thanks.

  • #2
    You could create a custom hook triggered on the save of the first entity that would send and set the information into the second entity. That solution would allow you to add logic to limit what records were saved in the second entity. You could probably do it using the formulas, but I'm better with hook logic then the formulas.

    Is that what you're trying to do?

    Comment


    • #3
      Hello,

      Thank you so much for the help Joy.

      With hook I can set all data to the existing entity(table), but how to create new entity(table) having all fields of another entity?

      Like I need to create another entity TEST, having all fields of account.

      Is that possible?

      Thanks,

      Comment


      • #4
        You could duplicate and rename the entity files in the system. I have done this for the advanced pack products section. I needed to keep track of several different product lines in different industries and for my purposes, it was easier to manage them separately. You'd have to locate all of the entity files and then make sure to copy and rename them and also open the renamed files and change the path or any of the connections to point to the new entity name. I'd make sure to create a backup of your Espo and database beforehand though.

        If you're actually trying to have a test version it would be better to have a separate install for development. You can copy your custom folder and your client/custom folder over to have the same modifications.

        Comment


        • #5
          Thanks for your response Joy.

          I wanted to try if there is any way we can do this duplication with simple lines of code.

          Thanks again Joy.

          Comment

          Working...
          X