best way to change a field name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 313

    #1

    best way to change a field name?

    I need to change the names of many fields to comply with a new naming convention, and I was wondering if there is an official way to do this?

    deep wiki has recommended this to me
    1. Create New Field: Go to Administration > Entity Manager > [Your Entity] > Fields and create countrySales with the same type as shippingCountry FieldManager.php:50-55 .
    2. Migrate Data: Execute a SQL query via your database tool:UPDATE `your_entity_table` SET country_sales = shipping_country;
    3. Update Layouts: Add the new field to your Detail/Edit layouts in Administration > Entity Manager > [Your Entity] > Layouts Renamer.php:312-318 .
    4. Delete Old Field: Once verified, delete shippingCountry from the Field Manager.

    is there any way to search though all workflows/flowcharts to find where the old value might be used?
    Last edited by jamie; 05-15-2026, 01:02 PM.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1876

    #2
    From my experience, the best way would be to recreate the entities. many fields mean also: many relationships, language files, dynamic conditions, layouts, many files, where there will be occurrences of the terms. I tried it, even created PHP scripts (forms) to recollect all the terms and manually change them, saving back to their locations. It took me many hours with the final result, that recreating would have been faster from the beginning. And I did not even start to "teach" all that to the database. I stopped, when it began to become a nightmare, before causing a desaster.

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 313

      #3
      Originally posted by shalmaxb
      From my experience, the best way would be to recreate the entities. many fields mean also: many relationships, language files, dynamic conditions, layouts, many files, where there will be occurrences of the terms. I tried it, even created PHP scripts (forms) to recollect all the terms and manually change them, saving back to their locations. It took me many hours with the final result, that recreating would have been faster from the beginning. And I did not even start to "teach" all that to the database. I stopped, when it began to become a nightmare, before causing a desaster.
      yeah i have looked at scripting it and i feel if i knew everywhere a filed name might show up it wouldn't be too difficult

      yuri would be great to have some official documentation on this as refactoring is a vital part of all tech life cycles

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1402

        #4
        Originally posted by jamie
        I need to change the names of many fields to comply with a new naming convention, and I was wondering if there is an official way to do this?

        deep wiki has recommended this to me
        1. Create New Field: Go to Administration > Entity Manager > [Your Entity] > Fields and create countrySales with the same type as shippingCountry FieldManager.php:50-55 .
        2. Migrate Data: Execute a SQL query via your database tool:UPDATE `your_entity_table` SET country_sales = shipping_country;
        3. Update Layouts: Add the new field to your Detail/Edit layouts in Administration > Entity Manager > [Your Entity] > Layouts Renamer.php:312-318 .
        4. Delete Old Field: Once verified, delete shippingCountry from the Field Manager.

        is there any way to search though all workflows/flowcharts to find where the old value might be used?
        Hi Mate,

        One option would be to just change the fields names in entityDefs of your entity > then change names in the database table and only after that do a rebuild (in theory this should work) - maybe worth optimizing the database table before running php bin/command rebuild.

        It is worth trying this in a staging env.
        Rabii
        EspoCRM Custom Development

        🔗 Portfolio & Builds

        Comment

        • jamie
          Senior Member
          • Aug 2025
          • 313

          #5
          Originally posted by rabii

          Hi Mate,

          One option would be to just change the fields names in entityDefs of your entity > then change names in the database table and only after that do a rebuild (in theory this should work) - maybe worth optimizing the database table before running php bin/command rebuild.

          It is worth trying this in a staging env.
          yeah is that the best way? what about all the formulas and workflows?

          would be great to have some documentation around this as its a very common thing for any evolved system

          Comment

          • rabii
            Active Community Member
            • Jun 2016
            • 1402

            #6
            Yeah best way to do it is as explained - below steps you can follow and it should work.
            1. Put the application in maintenance mode
            2. Disable cron and wait 5 minutes to make sure all running jobs have a chance to complete
            3. Rename the column in the database
            4. Update the entityDefs file with the new name
            5. Grep the project for references to the old field. Update as necessary
            6. Search workflows, processes, BPM flowcharts, frontend scripts, and API clients for references to the old field. Update as necessary
            This should work fine. Another option is to build your own command to use to rename which in theory should scan all and replaced the name with given name.
            Rabii
            EspoCRM Custom Development

            🔗 Portfolio & Builds

            Comment

            • jamie
              Senior Member
              • Aug 2025
              • 313

              #7
              Originally posted by rabii
              Yeah best way to do it is as explained - below steps you can follow and it should work.
              1. Put the application in maintenance mode
              2. Disable cron and wait 5 minutes to make sure all running jobs have a chance to complete
              3. Rename the column in the database
              4. Update the entityDefs file with the new name
              5. Grep the project for references to the old field. Update as necessary
              6. Search workflows, processes, BPM flowcharts, frontend scripts, and API clients for references to the old field. Update as necessary
              This should work fine. Another option is to build your own command to use to rename which in theory should scan all and replaced the name with given name.
              yeah that feels about right i'll have to develop some scripts for this

              yuri could you give us a hint as to what db tables/colums one should be looking in?

              Comment

              • item
                Active Community Member
                • Mar 2017
                • 1569

                #8
                Hi

                Dear Jamie,
                as i see many post on forum about critisize (or lake. sorry my english without translate) .. you ask how rename a field correctly .. .

                For me my question : What is your skill for have named a field with a bad name ??

                I know, EspoCrm and Yuri and his teams brainstrom many and many for just add a feature or change something.

                Please Jamie, you are free to respond and not always @ ... Yuri ..

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

                Comment

                Working...