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

View-only custom field can't be set by APIv3

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.2, 4.4.6, 4.5
    • Fix Version/s: 4.4.11, 4.5.1, 4.5.5
    • Component/s: CiviCRM API
    • Labels:
    • Documentation Required?:
      None

      Description

      Steps to reproduce:

      1. Create a Custom field for Memberships of type MEMBERSHIP_TYPE_ID and set the 'View only' checkbox. (in my case, it is an integer field.)
      2. Run this PHP API code.

      $results = civicrm_api("Membership","create", array ('version' => 3,
      'contact_id' => $contact_id,
      'membership_type_id' => MEMBERSHIP_TYPE_ID,
      'status_id' => 1,
      'custom_'. CUSTOM_FIELD_ID => 123,
      )
      );

      Expected Results: The value '123' is saved to the custom field, because the 'View only' help text states that the features is intended to allow for values that are set by PHP.

      Actual results: The value is not set.

      Work-around: The value is set correctly if the 'View only' checkbox is unchecked for the custom field.

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              mchapman2000 Matt Chapman
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: