PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Changing Form ID

  1. vixvii
    Member

    Could you possibly help with a SQL function to change the ID of a form? I have a series of forms on my development server and then the same on my live server. But when migrating to the live server one form did not migrate properly and I had to recreate it, which resulted in the form having a different ID than on the development server.

    I would like to change the ID of the equivalent form on the development server to match the live server's form ID. This will make coding so much easier as I have to constantly change form IDs in the code.

    Any help on this will really be appreciated.

    Posted 13 years ago on Wednesday August 3, 2011 | Permalink
  2. Can you recreate the form on the development server to match the production server? If the environments were the same, the new form should get the same ID on the development server as it has on the live server. Changing the ID would be complicated and prone to error.

    Or, how about export all the forms from the live server and just import them on the development server? I would be sure to back up everything first, in case something goes wrong.

    Posted 13 years ago on Thursday August 4, 2011 | Permalink
  3. vixvii
    Member

    Chris, Thanks for the reply

    The problem started when I migrated (see topic http://www.gravityhelp.com/forums/topic/migrating-gravity-forms)

    This one form did not import properly on the live server when I migrated. I made a complete DB backup on the development server and restored on the live server. So my user registration form was there, but had no fields. So I exported it from the dev server and imported on the live server, which worked, but of course gave it a different ID.

    What kind of errors will I face if I had to change the ID? I'm thinking that I should maybe re-create my live server on the dev server if something goes wrong again.

    Posted 13 years ago on Friday August 5, 2011 | Permalink
  4. Hi vixvii.

    I had to do the same and ran into problems, when I changed the ID in the database.

    If you haven't created any other forms, then you can delete the form in the production site. That will delete all entries for that form as well, so don't do that if this is an issue.

    Before importing the form again, you'll need to reset the autoincrement id in the database. You can do that like this:

    ALTER TABLE <code>table_name</code> AUTO_INCREMENT=1

    You would need to do that for the following tables:

    wp_rg_form
    wp_rg_form_meta

    Then you can import your form and it should work as ID 1.

    I am sure you are aware of this, but be careful if this is on a live site, so make backups before. :-)

    Vayu

    Posted 13 years ago on Friday August 19, 2011 | Permalink
  5. vixvii
    Member

    Vayu,

    Thanks so much for this and I actually wasn't aware of this. I haven't attempted changing any IDs in the database just in case it breaks anything. My biggest problem is that I am now up to ID 18 with forms and I need to change form ID 7 to 13. So I am a bit cautious of this... For now I just replace the 7 in my code to a 13 on my live site. I am going to remove my dev site soon and copy my live site back to the dev server - hopefully without any form ID issues.

    But say I have an issue with importing Form ID 7 and I delete it before importing any other forms and set the Auto Increment back to 7, this should work to re-import Form ID 7?

    Thanks again!

    Posted 13 years ago on Friday August 19, 2011 | Permalink

This topic has been resolved and has been closed to new replies.