Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Bulk create/update action #180

Open
colemanw opened this issue Jul 4, 2019 · 2 comments
Open

Bulk create/update action #180

colemanw opened this issue Jul 4, 2019 · 2 comments

Comments

@colemanw
Copy link
Member

colemanw commented Jul 4, 2019

@eileenmcnaughton has requested an action that can add or update multiple records in one api request. This would basically be what the Replace action does but without the delete part. I propose the action be named Save with a signature like:

civicrm_api4('Email', 'save', [
  'records' => [
    ['id' => 123, 'email' => '[email protected]'],  // will update because id provided
    ['email' => '[email protected]', 'conact_id' => 456, 'location_type_id' => 1],  // will create
  ],
]);

Available parameters would be:

  • records: array of records to save (see above example)
  • reload: whether to force-reload all records to return in api results
  • defaults: default values to set for all new records being created (saves repetition in the records param)
@eileenmcnaughton
Copy link
Contributor

@colemanw in the process of doing bulkCreate I found it really helpful to have a defaults param - ie if I create 5 fields with largely the . same params I passed this last in as $defaults & it applied to all

@colemanw
Copy link
Member Author

colemanw commented Jul 4, 2019

@eileenmcnaughton ok have updated the description above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants