Answers.Body: <p>I found the same issue with two extensions on my site: Form core (aka afform) and Search kit.</p>
  <p>I checked my database and in the civicrm_managed table there were references to the option group, but the option group did not exist with the specified ID in the civicrm_option_group table.</p>
  <p>To fix this issue I:</p>
  <ul>
  <li>Disabled and uninstalled Form core (ignoring any error messages about the missing option group)</li>
  <li>Manually removed the broken entries from civicrm_managed, using:</li>
  </ul>
  <p><code>DELETE FROM civicrm_managed WHERE module = 'org.civicrm.afform';</code></p>
  <ul>
  <li>Re-installed Form core</li>
  </ul>
  <p>And the managed entities were then installed correctly.</p>
  <p>The same process worked for a similar problem with the Searchkit extension.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-01T10:06:46.237Z
Answers.LastActivityDate: 2022-09-01T10:06:46.237Z
Answers.UserDisplayName: John
Body: <p>Getting this error out of sudden: apparently the only thing changed was &quot;CRM/Core/Payment.php&quot; file moved to the custom php directory and a &quot;City&quot; field attribute changed to &quot;not required&quot;</p>
  <blockquote>
  <p>API error: 'afform_type' is not a valid option for field
  option_group_id on OptionValue.create( entity name form)&quot;</p>
  </blockquote>
  <p>Indeed, 'option_group_id' in the civicrm_option_value table is of type INT, while new record creation API call looks like this:</p>
  <blockquote>
  <p>[id] =&gt; 1303</p>
  </blockquote>
  <blockquote>
  <p>[is_active] =&gt; 1</p>
  </blockquote>
  <blockquote>
  <p>[option_group_id] =&gt; <strong>afform_type</strong></p>
  </blockquote>
  <blockquote>
  <p>[name] =&gt; form</p>
  </blockquote>
  <blockquote>
  <p>[value] =&gt; form</p>
  </blockquote>
  <blockquote>
  <p>[label] =&gt; Submission Form</p>
  </blockquote>
  <blockquote>
  <p>[weight] =&gt; 0</p>
  </blockquote>
  <blockquote>
  <p>[icon] =&gt; fa-list-alt</p>
  </blockquote>
  <blockquote>
  <p>[version] =&gt; 3</p>
  </blockquote>
  <p>This is clearly broken but I have not a slightest clue why: nothing has been changed since yesterday.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-31T14:19:14.170Z
Comments.Text: I'm having the same issue, and the error appears when trying to 'Install' the 'Form core' extension (previously called afform). This problem seems to emerge whenever CiviCRM tries to rebuild the managed entities list: ie: enabling/disabling modules/extensions.
Comments.UserDisplayName: John
Tags: <api><drupal-7>
Title: API error: 'afform_type' is not a valid option for field option_group_id on OptionValue.create( entity name form)"
ThreadText: # API error: 'afform_type' is not a valid option for field option_group_id on OptionValue.create( entity name form)"
  
  (Asked by: username_0 on 2022-07-27)
  
  Getting this error out of sudden: apparently the only thing changed was "CRM/Core/Payment.php" file moved to the custom php directory and a "City" field attribute changed to "not required"
  
  > API error: 'afform\_type' is not a valid option for field
  > option\_group\_id on OptionValue.create( entity name form)"
  
  Indeed, 'option\_group\_id' in the civicrm\_option\_value table is of type INT, while new record creation API call looks like this:
  
  > [id] => 1303
  
  > [is\_active] => 1
  
  > [option\_group\_id] => **afform\_type**
  
  > [name] => form
  
  > [value] => form
  
  > [label] => Submission Form
  
  > [weight] => 0
  
  > [icon] => fa-list-alt
  
  > [version] => 3
  
  This is clearly broken but I have not a slightest clue why: nothing has been changed since yesterday.
  
  **Tags:** api, drupal-7
  
  > **Comments:**
  > **username_1**: I'm having the same issue, and the error appears when trying to 'Install' the 'Form core' extension (previously called afform). This problem seems to emerge whenever CiviCRM tries to rebuild the managed entities list: ie: enabling/disabling modules/extensions.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-01. Score: 4 | Accepted answer
  
  I found the same issue with two extensions on my site: Form core (aka afform) and Search kit.
  
  I checked my database and in the civicrm\_managed table there were references to the option group, but the option group did not exist with the specified ID in the civicrm\_option\_group table.
  
  To fix this issue I:
  
  * Disabled and uninstalled Form core (ignoring any error messages about the missing option group)
  * Manually removed the broken entries from civicrm\_managed, using:
  
  `DELETE FROM civicrm_managed WHERE module = 'org.civicrm.afform';`
  
  * Re-installed Form core
  
  And the managed entities were then installed correctly.
  
  The same process worked for a similar problem with the Searchkit extension.
  
  
  ---
  
  