I have a created quick action on a custom object (Address). Below are the details:

  • Object Name: Address
  • Action Type: Create a record
  • Target Object:Task

The quick action has his layout set for creating a Task record. The ask is to capture user's location when the task is created using this quick action.

I have been researching the call a VF/JavaScript from within the Apex/Trigger but everywhere it is mentioned as "Not Possible". I have also try creating a whole custom Lightning component that fit into this quick action and has a same look and feel but since there multiple quick actions having different layouts the effort is too high on design front.

Appreciate your guidance on any feasible solution requiring minimal efforts.

  • 1
    Are you trying to get the geolocation to display the address on a map? Its unclear what your difficulty is. Is it with getting the geolocation coordinates from the address using a web a service? If so, which service are you trying to use? Also, web services can't be called from a trigger except asyncronously. – crmprogdev May 20 '17 at 17:13
  • Yes I want to capture the geolocation to use it later on a different page that shows their location on a map on a given date and time. My question is more on how to capture the location on standard save button. I haven't use any webservice as yet but if I need to then appreciate if you could show me how. – Aryansh04 May 22 '17 at 5:30
  • 1
    See these two links on Geolocation fields. An admin must enable the geo clean rule for each object to be able to use them. You'll need to enable those first and set up the service to populate or keep them up to date. See: SF Help & this section of Object Reference. Once you go thru those, come back & ask a more specific question with your code if you need more help. – crmprogdev May 22 '17 at 13:20
  • I'm absolutely aware of Geo-location field and compound fields. I'm not using them. I have 2 custom fields Latitude__c and Longitude__c on Task object which I need populate when standard save button is clicked. If it is achievable through calling a web-service from trigger then can you tell me which web-service to call? I assume I have to call it from future method. – Aryansh04 May 22 '17 at 15:40
  • You can call any service you have a license for such as Google, Yahoo, etc. If it's already stored in the contact or Account info, you won't need to use a web service at all. – crmprogdev May 22 '17 at 20:38