Answers.Body: <p>It sounds like what you are asking about are Custom Field Groups.</p>
  <p>A Custom Field Group is generally not accessible from the API as an entity. Instead, you access the Custom Fields within the Custom Field Group on the relevant entity (e.g. if you have a Custom Field Group for Contacts called mygroup and a Custom Field within it called myfield, you can access mygroup.myfield on the Contact entity).</p>
  <p>The only exception to this is Custom Field Groups that allow multiple values, which is only possible for Contacts. For these, the Group is accessible as an API Entity.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-17T14:17:47.797Z
Answers.Text: @Learn CiviCRM this is the correct answer.  I'll leave my answer up for future readers who are looking for the answer to the question of custom SQL tables.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-17T00:50:35.327Z
Answers.LastActivityDate: 2023-08-17T00:50:35.327Z
Answers.UserDisplayName: Lars SG
Answers.Body: <p>If you have database tables you created outside of CiviCRM, they can't be exposed to API4.  API4 relies on metadata stored in the DAO file for the entity, which you don't have.  To rectify this, you should use <code>civix</code> to generate an extension, to <a href="https://docs.civicrm.org/dev/en/latest/framework/database/schema-definition/" rel="nofollow noreferrer">create an XML representation of your data</a>, and to generate the DAO boilerplate.</p>
  <p>You should instead then export table, remove it, and install the extension. This will install the newly-defined table.  If it doesn't exactly match the old table, uninstall and try again until it does.  Then you can reimport the table to restore your data (if there was no data in the table this is unncecessary).</p>
  <p>Then, finally, you can place a file in your extension at <code>Civi/Api4/Yourentity.php</code> that reads:</p>
  <pre><code>&lt;?php
  
  namespace Civi\Api4;
  
  /**
   * Yourentitiy
   *
   * @searchable secondary
   * @since 5.65
   * @package Civi\Api4
   */
  class Yourentity extends Generic\DAOEntity {
  
  }
  </code></pre>
  <p>Clear cache, and it should be in API4.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T18:53:52.367Z
Answers.Text: Thanks for your quick response, those custom tables are created within CiviCRM, is it the same procedure and do we have a quicker way to do that? THANKS
Answers.UserDisplayName: Learn CiviCRM
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T19:50:08.963Z
Answers.Text: are your custom fields set as Searchable - that is the only thing which often causes them to not be available in other contexts, eg Search, Import. So may be same with API Explorer
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T20:51:18.623Z
Answers.Text: Thanks for your help. All the custom fields I can see those in the APIv4, is some of the custom field that has multiple values currently CiviCRM put them in tables where the table name as civicrm_value_XXXX which is not showing up under Entity in APIv4. Thanks and help.
Answers.UserDisplayName: Learn CiviCRM
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T20:58:18.763Z
Answers.Text: Sorry - are these *Custom Field Groups* created through the CiviCRM UI, with SQL tables that start with `civicrm_value_`?  Or are these *completely* custom tables you created directly in the SQL database?
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-17T07:45:08.890Z
Answers.Text: They are all created thru CiviCRM UI, Thanks a lot
Answers.UserDisplayName: Learn CiviCRM
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T16:02:13.453Z
Answers.LastActivityDate: 2023-08-16T16:02:13.453Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>we have some custom tables and in the menu, Support -&gt; Developer -&gt; Api Explorer v4, currently those custom tables are not available. Since we are new to this, in order for those custom tables to appear, we need to create our own extensions, install it then we can use it thru the APi Explorer v4, is it correct? Please give your suggestions. Thanks</p>
  
Tags: <custom-fields><extension><apiv4>
Title: Creating extensions for custom tables
ThreadText: # Creating extensions for custom tables
  
  (Asked by: username_0 on 2023-08-16)
  
  we have some custom tables and in the menu, Support -> Developer -> Api Explorer v4, currently those custom tables are not available. Since we are new to this, in order for those custom tables to appear, we need to create our own extensions, install it then we can use it thru the APi Explorer v4, is it correct? Please give your suggestions. Thanks
  
  **Tags:** custom-fields, extension, apiv4
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-08-17. Score: 3
  
  It sounds like what you are asking about are Custom Field Groups.
  
  A Custom Field Group is generally not accessible from the API as an entity. Instead, you access the Custom Fields within the Custom Field Group on the relevant entity (e.g. if you have a Custom Field Group for Contacts called mygroup and a Custom Field within it called myfield, you can access mygroup.myfield on the Contact entity).
  
  The only exception to this is Custom Field Groups that allow multiple values, which is only possible for Contacts. For these, the Group is accessible as an API Entity.
  
  > **Comments:**
  > **username_2**: @username_0 this is the correct answer.  I'll leave my answer up for future readers who are looking for the answer to the question of custom SQL tables.  
  
  ---
  
  ### Answer by username_2 on 2023-08-16. Score: 0
  
  If you have database tables you created outside of username_0, they can't be exposed to API4. API4 relies on metadata stored in the DAO file for the entity, which you don't have. To rectify this, you should use `civix` to generate an extension, to [create an XML representation of your data](https://docs.username_0.org/dev/en/latest/framework/database/schema-definition/), and to generate the DAO boilerplate.
  
  You should instead then export table, remove it, and install the extension. This will install the newly-defined table. If it doesn't exactly match the old table, uninstall and try again until it does. Then you can reimport the table to restore your data (if there was no data in the table this is unncecessary).
  
  Then, finally, you can place a file in your extension at `Civi/Api4/Yourentity.php` that reads:
  
  ```
  <?php
  
  namespace Civi\Api4;
  
  /**
   * Yourentitiy
   *
   * @searchable secondary
   * @since 5.65
   * @package Civi\Api4
   */
  class Yourentity extends Generic\DAOEntity {
  
  }
  
  ```
  
  Clear cache, and it should be in API4.
  
  > **Comments:**
  > **username_0**: Thanks for your quick response, those custom tables are created within username_0, is it the same procedure and do we have a quicker way to do that? THANKS  
  > **username_3**: are your custom fields set as Searchable - that is the only thing which often causes them to not be available in other contexts, eg Search, Import. So may be same with API Explorer  
  > **username_0**: Thanks for your help. All the custom fields I can see those in the APIv4, is some of the custom field that has multiple values currently username_0 put them in tables where the table name as civicrm_value_XXXX which is not showing up under Entity in APIv4. Thanks and help.  
  > **username_2**: Sorry - are these *Custom Field Groups* created through the username_0 UI, with SQL tables that start with `civicrm_value_`?  Or are these *completely* custom tables you created directly in the SQL database?  
  > **username_0**: They are all created thru username_0 UI, Thanks a lot  
  
  ---
  
  