Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C CiviCRM Core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,372
    • Issues 1,372
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • CiviCRM Core
  • Issues
  • #2538
Closed
Open
Created Apr 15, 2021 by eileen@eileen🎱Owner

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
});
status_id participant_status_id Status ID /(participant.)?(status)$/i true int unsigned true true 1 Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered. 1.7 civicrm_participant_status_type
id label Select Status

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".....}'
  ]
]);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking