-
-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow values to be passed to api4 GetFields #16154
Conversation
(Standard links)
|
@colemanw just checking if you say specified contact_type as individual will this still return custom fields where no contact_type has been specified?, Also do we need to consider the subtype as well? |
So far this only filters custom fields by contact type, but values is now being passed to allow more filtering.
@seamuslee001 I've fixed the style warning. |
$getFields = Contact::getFields()->setCheckPermissions(FALSE); | ||
$this->assertContains('MyIndividualFields.FavColor', $getFields->execute()->column('name')); | ||
$this->assertContains('MyIndividualFields.FavColor', $getFields->setValues(['contact_type' => 'Individual'])->execute()->column('name')); | ||
$this->assertNotContains('MyIndividualFields.FavColor', $getFields->setValues(['contact_type' => 'Household'])->execute()->column('name')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seamuslee001 this test asserts that fields for Individual are returned even if no contact type is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemanw i was more thinking of if you specified Individual in the contact type when doing a getfields that custom fields for All contacts are still returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does.
@seamuslee001 once this is merged I have a couple followup PRs for further improvements. |
I think this is OK to merge - it's a new api feature with a test & I think we still want to keep apiv4 moving fairly fluidly |
Overview
When doing GetFields from the api, some fields only apply to certain contact types.
This is a step toward getting filtering on api4 getFields by accepting
values
as a param.Before
GetFields returns all fields.
After
It's now possible to filter getFields by contact type, only returning custom fields appropriate to certain contact types.
Technical Details
This also fixes a bug where multi-record custom sets were being returned in contact getFields.
Comments
So far this only filters custom fields by contact type, but values is now being passed to allow more filtering in future.