0

I'm trying to update the ID of an existing OptionValue using API v4. I get "Cannot update the id of an existing OptionValue" error. Is there another way to do that?

  • id is an autoincremented value in DB which should be set by DB itself. Updating the id directly in such a way is not a very good idea. Can you let us know what you are trying to achieve? – jitendra - fuzion Dec 13 '19 at 9:12
  • Jitendra I'm trying something to fix this, see civicrm.stackexchange.com/q/33833/186 – Joe McLaughlin Dec 13 '19 at 15:36
  • Are you sure it's the "id" you want to update? For option values it's usually the value in the "value" column that gets used and/or stored in the foreign table, if you're trying to fix something that got out of whack. – Demerit Dec 13 '19 at 23:36
  • @Demerit yeah it was definitely the ID. I was able to do it using mysql at the command line. I was attempting to fix the problem in the Q linked in the above comment, changing the didn't do the trick. I had deleted the City, County and State/Province option values in Addressing Options, duh on me, then added them back in, but of course they had a new auto-incremented ID number. I thought that restoring to the previous ID would fix the problem with the City, County and State/Province not appearing when editing an Address in the Summary screen. – Joe McLaughlin Dec 13 '19 at 23:58
1

As said by Jitendra, you cannot update the id via CiviCRM api. The id in civicrm tables are autoincremented and are referenced at many places. If you still want to take risk than you can run a sql query in mysql to update the id of required row in civicrm_option_value table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.