Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/choefele/salesforce-geo


https://github.com/choefele/salesforce-geo

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# Salesforce Location Experiments

## Storing Coordinates in Contact

* [Find coordinate](https://www.gps-coordinates.net)
* Update coordinate on `Contact`:
```
List contacts=[select Id, Name from Contact where LastName='Test' limit 1];

if (!contacts.isEmpty()) {
Contact contact=contacts[0];
contact.MailingLatitude = 52.520904;
contact.MailingLongitude = 13.351403;
update contact;

System.debug('Updated contact: ' + contact);
} else {
System.debug('Contact not found');
}
```
* Query `Contact`s ([reference](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_geolocate.htm)):
```
SELECT Id, Name, MailingLatitude, MailingLongitude
FROM Contact
ORDER BY DISTANCE(MailingAddress, GEOLOCATION(37.775,-122.418), 'km')
LIMIT 10
```