CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • SOLVED! Issue with API to create custom data group
Pages: [1]

Author Topic: SOLVED! Issue with API to create custom data group  (Read 872 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
SOLVED! Issue with API to create custom data group
June 15, 2012, 07:26:14 pm
I am calling the API to create a custom data set that extends "Organizations" of type "Primary Organization". ( This is a custom contact subtype that I previously created in the UI)

My code is:
Code: [Select]
$params_a = array(
                'title'            => 'Update Test Group 1',
                'name'             => 'update_test_group_abc',
                'extends'          => array(  'Organization', array('Primary Organization')) ,
                'extends_entity_column_id' => 4,
                'weight'           => 1,
                'collapse_display' => 0,
                'style'            => 'Inline',
                'help_pre'         => 'This is Pre Help For Test Group 1',
                'help_post'        => 'This is Post Help For Test Group 1',
                'is_active'        => 1
                );

require_once("api/v2/CustomGroup.php");

$customGroup_a =& civicrm_custom_group_create($params_a);

But the resulting custom field group only extends organization, NOT my contact subtype.     The output array of the API is:
(
    [id] => 25
    [name] => update_test_group_abc
    [title] => Update Test Group 1
    [extends] => Organization
    [extends_entity_column_id] => null
    [extends_entity_column_value] => Primary Organization
    [style] => Inline
    [collapse_display] => 0
    [help_pre] => This is Pre Help For Test Group 1
    [help_post] => This is Post Help For Test Group 1
    [weight] => 1
    [is_active] => 1
    [table_name] => civicrm_value_update_test_group_1_25
    [is_multiple] =>
    [min_multiple] =>
    [max_multiple] => null
    [collapse_adv_display] =>
    [created_id] =>
    [created_date] =>
    [is_error] => 0
)

« Last Edit: June 17, 2012, 08:37:17 am by Sarah Gladstone »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Issue with API to create custom data group
June 15, 2012, 10:47:56 pm
Don't use API v2 it is not supported. Try with v3
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with API to create custom data group
June 16, 2012, 06:23:07 am
I updated my code to use API version 3, but I am having the same issue.

The return value from calling the API is:
 [is_error] => 0
    [version] => 3
    [count] => 1
    [id] => 26
    [values] => Array
        (
            [26] => Array
                (
                    [id] => 26
                    [name] => update_test_group_abc
                    [title] => Update Test Group 1
                    [extends] => Organization
                    [extends_entity_column_id] => null
                    [extends_entity_column_value] => Array
                        (
                           
  • => Primary Organization

                        )

                    [style] => Inline
                    [collapse_display] => 0
                    [help_pre] => This is Pre Help For Test Group 1
                    [help_post] => This is Post Help For Test Group 1
                    [weight] => 1
                    [is_active] => 1
                    [table_name] => civicrm_value_update_test_group_1_26
                    [is_multiple] =>
                    [min_multiple] =>
                    [max_multiple] => null
                    [collapse_adv_display] =>
                    [created_id] =>
                    [created_date] =>
                )

        )
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Issue with API to create custom data group
June 17, 2012, 08:36:56 am
I figured out the issue. I needed to use the name of the contact sub type, not the label as an API parameter.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: SOLVED! Issue with API to create custom data group
June 17, 2012, 11:16:03 pm
Cool,

I don't know if it is what you did, but I find way easier to use the api explorer to discover & find the right parameter than changing code

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: SOLVED! Issue with API to create custom data group
October 02, 2012, 07:27:26 am
Could anyone clarify the API call required to link a custom group create to a sub-type? Sarah says she has solved it, but I've tried using the sub-type's label in an array within the "extends" parameter with no luck.

A little help would be appreciated.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • SOLVED! Issue with API to create custom data group

This forum was archived on 2017-11-26.