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


                • jamie
                  jamie commented
                  Editing a comment
                  Hi Item,

                  thats an utterly funny translation i wonder what language you speak? feel free to post in your own language i am happy to do the translations my side

                  this is an on going issue i have here where i raise a legitimate question such as this one but only when i make some comment about espo or the docs does yuri come in and say that i am wrong for even asking, i'd say look though the forum but he deletes anything he doesn't like so there is no real discussion or help, no i don't agree with how the conversations go and it is a waste of time. but i'm stuck with using espo for the foreseeable future and asking for better documentation for an 11 year old project isn't that strange, and the lack of it seems to show the contempt for users

                  the reason i do a @ yuri is to get discussion on here where its constructive and not else where where its not. still he seems to be much more about arguing with me than clarifying what should be in the documentation



                  ##but onto this topic

                  i have inherited a massive system built over many years by a dev ops person not a developer and the variable names are all over the show and its starting to cause issues with development so i just wanted absolute clarity about what i need to do for a basic refactor something that is an essential part of any development life style

                • shalmaxb
                  shalmaxb commented
                  Editing a comment
                  Customers are vital to any business, and customer relation management (CRM) software enables you to maximize every interaction. We help you choose the right CRM for your business based on our in-depth testing.
              • yuri
                EspoCRM product developer
                • Mar 2014
                • 9834

                #9
                Renaming field names is not supported. We can document only things that are supported. We could have guidelines but with a disclaimer that it's not guaranteed. A field can be referenced in many places, such as workflows, flowcharts, formula, custom code.

                I'd suggest leave the field named as it is, a pragmatic way of handling such issues.

                Comment

                Working...