I found the API CSV IMPORT GUI that allows me to import events. The one thing I can't figure out how to map is the location details - city and state. How do I map those two items?


The address is stored in an Address entity. You then create a LocBlock entity that links to that address ID, and the event references the loc_block_id.

This is a bit tricky to do with the CSV API Import GUI because it only supports importing one entity at a time, as opposed to using API Chaining. There are several approaches that support API chaining but unfortunately they're all significantly more complicated than API CSV Import GUI.

If you'd like a manual method:

  • Note the max ID in civicrm_address (SELECT MAX(id) from civicrm_address).
  • Import your event addresses. Note the new max ID.
  • Note the max ID in civicrm_loc_block (SELECT MAX(id) from civicrm_loc_block).
  • Create a spreadsheet with a list of new address IDs only. Import that as a LocBlock entity, mapping to address_id.
  • Note the max ID in civicrm_loc_block.
  • Paste the loc_block_id into your original event spreadsheet as a new column. If you successfully imported all addresses in the same order as they appear on the event CSV, your loc_block_ids should line up.
  • Import the events.
  • It seems pretty stupid to create something that allows for you to import a large number of events, yet you can't add the address to them. So now you have to go through and edit all those events manually to add the address. Guess I'll just go through all 1,700 events and manually add the city & state. – Jenni Simonis Jul 4 '18 at 3:32
  • @jennisimonis - The CSV API Import GUI is just a front-end on the API, a shortcut to avoid writing extensions. However, if you'd like to write the extension that does this in one step, it's an excellent starter project! Come join us at chat.civicrm.org in ~dev-newcomers, folks will be happy to help. – Jon G - Megaphone Tech Jul 4 '18 at 4:37
  • Unfortunately that's well outside my expertise. I know just enough PHP and SQL to be dangerous. ;) – Jenni Simonis Jul 5 '18 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.