API4: 500 error on chain with custom field
In API Explorer, I created two API chained commands. When I chain using the contact ID, it works; with a contact reference custom field, it fails.
Works
$contributions = \Civi\Api4\Contribution::get()
->addSelect('contact_id')
->setChain([
'name_me_0' => ['Contact', 'get', ['where' => [['id', '=', '$contact_id']]], 0],
])
->execute();
foreach ($contributions as $contribution) {
// do something
}
Fails
$contributions = \Civi\Api4\Contribution::get()
->setSelect([
'contact_id',
])
->addWhere('contact_id', '=', 127364)
->addWhere('contribution_status.value', '!=', 'Pending')
->addOrderBy('receive_date', 'ASC')
->setChain([
'name_me_1' => ['Contact', 'get', ['where' => [['id', '=', '$gift_details.Acknowledgee']]], 0],
])
->setCheckPermissions(FALSE)
->execute();
foreach ($contributions as $contribution) {
// do something
}