We are creating Component for addresses, and on save of the Component would like to trigger a Save event and get the latitude and longitude values of the address and populate Latitude and Longitude fields of the address in a Component. Please suggest.
1 Answer
If you haven't tried anything yet (see the question from my comment), then here is a good place to start. The documentation defines every step that you need to do (creating the extension, configuring, deploying) and also answers which type of subscription you would need. In your case, this would be synchronous.
Subscribe synchronously to an event. Select this method if your Event Handler code changes the data being handled. For example, if your Event Handler analyzes a Component and then adds metadata to it, ensure that you select this method.
Just keep in mind that the Save action will be blocked until your handler finishes, so try to optimize this as much as possible (as you will most likely be contacting some service for obtaining the coordinates),
I would first check the Schema of the Component to see whether the Component being saved is of interest at all. Another improvement point is to update the coordinates only when a new Component is being saved. Places tend not to change their coordinates :) so subsequent saves to those Components should not trigger the event handler.
And finally, you have a complete example right here.