Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-18591

group_type parameter ignored when using API to create group

    Details

    • Versioning Impact:
      Major (incompatible API change)
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Contributed Code

      Description

      To reproduce: run the following.

      CRM.api3('Group', 'create',

      { "title": "My Mailing List", "group_type": ["2"] }

      );

      CRM.api3('Group', 'getsingle',

      { "return": ["group_type"], "title": "My Mailing List" }

      );

      The result is:

      { "group_type": [ "0" ], "id": "9" }

      Note that the group_type is 0, not 2 as specified.

      It turns out that the following format will successfully create the group with group_type 2:
      CRM.api3('Group', 'create', {
      "title": "My Mailing List",
      "group_type":

      {"2": "1"}

      });

      However this parameter format is undocumented, cumbersome and AFAIK unnecessary. It is also different from the format given by the api "get" action.

      The attached patch seems to fix this bug. Something like the following line of documentation would also help:

      The group_type parameter should be an array of values from the "Group Type" Option Group.

        Attachments

          Activity

            People

            • Assignee:
              monish.deb Monish Deb
              Reporter:
              noah Noah Miller
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: