0

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
  • 2
    What you want to achieve is perfectly doable, but might I ask what exactly is your question? Have you tried anything and got stuck somewhere? If yes, please post your current code so that we can assist you.
    – Atila Sos
    Commented Mar 7, 2019 at 22:10

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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