2

I have contacts with an Alphanumeric/CheckBox custom field on, and I have relationships with an Alphanumeric/CheckBox custom field on. (The former is legacy and is copied into the latter.) These seem to be returned differently when using the getsingle API call. Why is this?

For example:

$ drush -u <uid> cvapi Contact.getsingle id=<cid> contact_type=Individual contact_sub_type=Student return=custom_42
Array
(
    ...
    [custom_42] => Array
        (
            [0] => Fundraise_Donate_for_specific_school_needs
            [1] => Apply_to_become_a_Governor
            [2] => Be on a poster displayed in your old school/college
        )
    ...
)

but:

$ drush -u <uid> cvapi Relationship.getsingle id=<rid> relationship_type_id=21 return=custom_112
Array
(
    ...
    [custom_112] => Array
        (
            [Fundraise_Donate_for_specific_school_needs] => 1
            [Apply_to_become_a_Governor] => 1
            [Be on a poster displayed in your old school/college] => 1
        )
    ...
)

CustomValue.get, however, returns the same format for the Contact and the Relationship field, and that format is more like the Contact one above.

1

This is a known issue: CRM-15915. I created a pull request so that the format of your 1st example is used everywhere, but that pull request was closed in favour of another one. This one still has some issues, as it seems.

1

If the custom fields are of the same type, i think you should log an "Improvement" issue in JIRA for this. It's not really a bug but i think Api should be consistent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.