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

Cannot create campaign with custom values through api

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5.4
    • Fix Version/s: 4.6
    • Component/s: CiviCRM API
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      At the moment it is possible to create campaign's throught the api.
      Although when your campaign has custom fields, it's not possible to create a campaign with values for this custom fields.

      Executing $result = civicrm_api3('Campaign', 'create', array(
      'sequential' => 1,
      'title' => "",
      'custom_field' => "value custom field",
      ));

      has the same result as if you would omit the custom field value.

      This is because the basic create method is used for the api create call.
      (In api/v3/Campaign.php we have)
      function civicrm_api3_campaign_create($params)

      { return civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); }

      If we change this code (as in other entities wich do allow custom fields) we can make this work.

      function civicrm_api3_campaign_create($params)

      { $value = array(); _civicrm_api3_custom_format_params($params, $values, 'Campaign'); $params = array_merge($values, $params); $campaignBAO = CRM_Campaign_BAO_Campaign::create($params); _civicrm_api3_object_to_array($campaignBAO, $campaign[$campaignBAO->id]); return civicrm_api3_create_success($campaign, $params, 'campaign', 'create', $campaignBAO); }

      I'll try to make a pull request

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                eileen Eileen McNaughton
                Reporter:
                mallezie Tim Mallezie
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: