Using civicrm api4, what's the best way to chain save a contact so that the email updates, without creating a new one?
For example, I want to update this existing contact:
entity: Contact, action: get, version: 4, count: 1
(1) [
{
"id": 2,
"first_name": "Michael",
"email.email": "[email protected]"
}
]
... to have first_name: "Mike" and email: "[email protected]". So, I tried:
crmApi4('Contact', 'save', {
records: [{"id":2, "first_name":"Mike"}],
chain: {"name_me_0":["Email", "save", {"records":[{"contact_id":"$id", "email":"[email protected]"}]}]}
})
That correctly updates the first name, but creates a new email:
entity: Contact, action: get, version: 4, count: 2
(2) [
{
"id": 2,
"first_name": "Mike",
"email.id": 2,
"email.email": "[email protected]"
},
{
"id": 2,
"first_name": "Mike",
"email.id": 11,
"email.email": "[email protected]"
}
]
How can I get it to simply update the existing email?