APiv4 fk vs pseudoconstant
@colemanw we recently removed the pseudoconstant for campaign_id from a bunch of fields but there is a benefit to the pseudoconstants I didn't realise - with both declared I can use
CRM.api4({participants: ['Participant', 'get', {
where: [["status_id:name", "=", 'Attended']],
limit: 25
}]}).then(function(batch) {
// do something with batch.participants array
}, function(failure) {
// handle failure
});
But the same doesn't work on campaign anymore
CRM.api4('Participant', 'get', {
where: [["campaign_id:name", "IS NULL"]],
limit: 25
}).then(function(participants) {
// do something with participants array
}, function(failure) {
// handle failure
});
I think this is a bigger issue on create where you might want to pass a machine name to a required FK field - in my case it looks like (
civicrm_api4('SearchDisplay', 'create', [
'values' => [
'name' => 'Equivalent_names',
'label' => 'Equivalent names',
'saved_search_id:name' => 'Equivalent_names',
'type' => 'table',
'settings' => '{"limit":20,"pager":true,"columns":[{"key":"name_a","label".....}'
]
]);