Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/choefele/salesforce-geo
https://github.com/choefele/salesforce-geo
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/choefele/salesforce-geo
- Owner: choefele
- Created: 2020-05-10T12:00:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T16:00:05.000Z (over 4 years ago)
- Last Synced: 2024-10-15T09:53:25.858Z (3 months ago)
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```