How Geopointe for Your Salesforce Instance is Developer Friendly

 

Just as a well-constructed garment can be tailored to fit you perfectly, a well-constructed software application can be tailored to fit your business perfectly. Not only is Geopointe the most popular mapping application on the Salesforce AppExchange, it’s the only app that offers APIs that enable developers to seamlessly integrate our powerful off-the-rack features with your custom business processes.

Geopointe has an Apex API focused on data-related needs and a  Javascript API for customizing the user experience (UX) on the Map page. In this post, we’ll explore a complicated assignment process and show how our Apex API can be leveraged to completely automate the process.

The Hypothetical Assignment Process 

The Need:

CleanIt, a cleaning service business, has an online scheduling service where customers can enter their address, desired date of service, and whether the location is a residence or business. They also have hundreds of cleaning providers with overlapping service areas. When a service request comes in, CleanIt needs to determine which providers’  service areas cover that location for that type of service (residential/business). Then, from that pool of candidate providers, CleanIt uses a custom formula that factors in driving distance, provider rating, and availability to determine which provider is assigned to the service request. After assigning the service request to a provider, notify the customer of the service provider’s name and contact info.

The Result:

If done manually, it can take hours or days before the customer is sent a confirmation with their service provider’s info. By using Geopointe and Geopointe’s Apex API, CleanIt can now notify the customer within seconds or minutes and requires no interaction with CleanIt’s staff.

Real-time Geocoding

After the online form creates the service request, the first thing that needs to get figured out is where the address is. Geopointe allows admins to turn on real-time geocoding for certain standard objects via the Geopointe Setup UI (user-interface). The Geopointe Apex API can be used to enable real-time geocoding for any object. There are a few methods for geocoding, but in this scenario, CleanIt would create a service request trigger and when a service request is created, called geopointe.API.geocodeRecords.

Example: 
geopointe.API.geocodeRecords(null, Trigger.new, null, null);

After geocoding the record, we need to determine the candidate pool of providers. There are two common ways businesses define providers’ service areas. In the first approach, the service area is a circular area around the provider. A radial or proximity search would be used to retrieve the matching providers. In the second approach, each provider has a territory of arbitrary shape and size. For this scenario, assignment plans and territory assignments would be used to determine in whose territories an address is located. CleanIt’s service request trigger will also determine when the record has been successfully geocoded and then perform either a proximity search or territory assignment, as described below, to get the candidate vendor pool.

Proximity Searches

Proximity is an important factor in many of our decisions. Which service center is closest to the driver?  Which home cleaning service with availability is closest the house?  Which venue has the highest density of potential customers around it?  Our radial search API methods can be used to answer these questions.

The Geopointe Apex API has a number of radial search methods. You can search around a record or around a set of latitude and longitude coordinates. You can also either run a dataset search – which includes any custom filters you’ve already defined on it – or run a search on a map object. In our example scenario, CleanIt has two data sets – one that filters on residential services and one that filters on business services. Their residential service providers have a 20-mile radius service area, and their business service providers have a 40-mile radius service area. After a Service Request is geocoded, the trigger would perform a search like:

Example:
geopointe.API.RadialSearchResult result;
if (sr.residential__c)
result = geopointe.API.radialSearchDataSet(sr.Id, ‘12121212121212.18644033148613703’, 20, geopointe.API.units.MILES)
else result = geopointe.API.radialSearchDataSet(sr.Id, ‘34343434343434.12341234148613444’, 40, geopointe.API.units.MILES)

Territory Assignments

On the other hand, what if CleanIt needs to define custom polygon service areas for each provider? Geopointe provides a number of ways to manage territories and record assignments. It can be done interactively on the map: add shapes, map records and use the field update or change owner features to assign records en masse. Users can also use assignment plans to automate the process and assign records on an hourly schedule. But, sometimes, every hour just isn’t fast enough. When territories need to be assigned immediately, the Geopointe Apex API offers the assign records method. Determining territory assignments is a complex process, and therefore must be done asynchronously due to Salesforce.com‘s governor limits. To allow your code to know when the assignments are complete, the assignRecords method can be passed the name of a callback class to invoke. When the assignment plan is fully processed, it will invoke your callback so that your custom processes can continue working after the record has been assigned.

In this particular example, where territories overlap, CleanIt would create a Geopointe assignment plan that uses a custom assignment object. After the service request is successfully geocoded, the trigger would call a queueable class, which would then call Geopointe.API.assignRecords. (The queueable class is needed because assignRecords will start a batch job, and you can’t start batch jobs from a trigger.)

Example:
In the Service Request trigger:
System.enqueueJob(new AssignServiceRequests(requestIds));

In the Queueable class AssignServiceRequests.cls:
geopointe.API.assignRecords(requestIds, planIds, ‘AssignServiceRequestCallback’);

Driving Distance

We’re almost done! The straight-line distance between two points is easy to calculate and can be useful in the right circumstances. Both Salesforce and the Geopointe Apex API provide methods to calculate it! But straight-line distance can be very misleading at times. Particularly in areas of restricted access (e.g., rivers, bays, mountains), the driving distance could vary significantly from the straight-line distance. As part of the Apex API, Geopointe provides the Distance Service API for driving distance calculations.

In our example, either after the radial search is complete or in AssignServiceRequestCallback after the territory assignments are completed, the driving distance between the customer and each vendor can be calculated using the Geopointe Distance Service API. CleanIt can then take those distances, incorporate other factors such as availability and vendor rating to determine which vendor gets the customer. The code populates a field on the service request and notifies the customer of the vendor’s name and contact info.

And, voila!  What used to take hours to days now takes seconds to minutes.

These are just some of the ways our API can be leveraged to streamline your business by automating processes that can be time-consuming or impractical to do interactively. Explore more of what our Geopointe’s APIs can do on our help site.


Ready to add the power of Geopointe’s API to your Salesforce instance? Get started with a 15-day Free Trial period today!

.


Related Posts