Skip to content
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

APIv4 - Read & write contact primary and billing locations as implicit joins #23972

Merged
merged 2 commits into from
Aug 9, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jul 8, 2022

Overview

Makes it easier to search and display contact primary email, phone, im without using any joins in SearchKit.
Both read & write are supported.
See dev/core#3659

image

Before

In SearchKit, you must add an explicit join if you want to view a contact's address, phone, email, etc.

After

Declares an implicit join between the contact record and primary/billing email, phone, address & im records, making it easier to retrieve those directly from the Contact API.
Read and write both supported. Also you can pass NULL to delete them.

@civibot
Copy link

civibot bot commented Jul 8, 2022

(Standard links)

@civibot civibot bot added the master label Jul 8, 2022
@colemanw colemanw marked this pull request as ready for review July 8, 2022 12:56
@colemanw colemanw changed the title APIv4 - Allow write to contact primary and billing locations APIv4 - Read & write contact primary and billing locations as implicit joins Aug 2, 2022
Declares an implicit join between the contact record and primary/billing email, phone, address & im records,
making it easier to retrieve those directly from the Contact API.
Provides symmetry with get operations, allowing email, phone, address & im to be
both read and written to within the contact api.
@eileenmcnaughton
Copy link
Contributor

@colemanw so the expectation is that if the contact has a street address & I update address_primary.postal_code it will NOT overwrite the full primary address (I think that is OK but it could be argued either way)

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Aug 9, 2022

In my testing I find that for get

$contacts = \Civi\Api4\Contact::get()
  ->addSelect('address_billing.street_address', 'address_billing.postal_code', 'address_billing')
  ->addWhere('id', '=', 55)
  ->execute();

Returns the following

image

I find the returning of an id for address_billing odd - but I'm sure you have previously advised me there is precedent for that.

For create and update I do NOT see anything advertised in the api explorer for them

@eileenmcnaughton
Copy link
Contributor

While not api advertised it seems the update does work

CRM.api4('Contact', 'update', {
  values: {"address_billing.street_address":"Household"},
  where: [["id", "=", 55]]
})

@eileenmcnaughton eileenmcnaughton added the merge ready PR will be merged after a few days if there are no objections label Aug 9, 2022
@eileenmcnaughton
Copy link
Contributor

I don't think the explorer thing is blocking - & I think the update behaviour for address is consistent with v3 so I think this is probably fine

@eileenmcnaughton
Copy link
Contributor

On reflection I'm going to merge this so it hits the rc - I know you were wanting it to & we could update the rc with the outcome of any further discussion is need be

@eileenmcnaughton eileenmcnaughton merged commit 5d77736 into civicrm:master Aug 9, 2022
@eileenmcnaughton eileenmcnaughton deleted the primaryLocationWrite branch August 9, 2022 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants