1

I recently created some custom fields and some new event types for events. Now I need to edit each event to change the event type, as well as populate those custom fields, for 5 years worth of events. I just need to edit 3 fields: the event type and 2 new custom event fields.

I tried making a custom profile so I could do an export/import, but I guess custom profiles are not supported for events.

A search of stackexchange suggests there is really no way to bulk edit event information.

Would it be horrifying if I made the edits manually in the database? Any other suggestions on options to edit event data in bulk?

Thank you!

4

You could do this using chaining in the API, either by script or with the API Explorer.

Eg:

$result = civicrm_api3('Event', 'get', [
  'sequential' => 1,
  'options' => ['limit' => 0],
  'event_type_id' => "Fundraiser",
  'api.Event.create' => ['id' => "\$value.id", 'event_type_id' => "Meeting"],
]);

Or in words: find all the events of type Fundraiser. For each one, use the 'create' API call with the id of the found event and set the type to Meeting.

To run this in API Explorer you need to enter the chained part as json:

enter image description here

3
  • Wow! I had no idea the API explorer could do this. Thank you!! Sep 21 '19 at 4:13
  • So, just to be clear, even though I am calling api.Event.create, because I am providing it with the ID of an existing event, it acts more like a modify than a create? It won't create duplicate events, surely? Sep 21 '19 at 4:14
  • That's right - calling 'create' with an id is the way that you update an existing entity. In the example above, it will change the event type of the existing event to Meeting and will leave all other fields unchanged.
    – Aidan
    Sep 23 '19 at 7:36
3

One option would be to test if this API import solution can get the data where you need it

https://github.com/eileenmcnaughton/nz.co.fuzion.csvimport

(but yes otherwise I would be heading down the update in the db route)

1
  • Thank you! Glad to know I'm not insane for considering straight db edits. The db structure for events and event metadata does not appear sooo super complicated. Sep 20 '19 at 4:57

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .