Represents the result of using the getTerritoryIdByPolygons method to return a service territory record ID using latitude and longitude geolocation values.
Before calling the PolygonUtils class, make sure that you have existing map polygon records that are associated with a service territory.
If Base service appointment territories on polygons is enabled, global actions consume this class to populate the Service Territory field on service appointments. When standard FSL Global Actions are not being used, you can use the getTerritoryIdByPolygons method to populate the Service Territory lookup field on objects.
If getTerritoryIdByPolygons doesn’t find a territory it returns null.
This method returns a service territory record ID from longitude and latitude values. If a service appointment’s geolocation matches more than one polygon, the appointment is assigned to either the highest or lowest-level territory in the hierarchy depending on your settings.
Example
This example retrieves a service territory record ID using latitude and longitude geolocation fields.
1//fetch Service Appointment record(s)2List<ServiceAppointment>sas = [select id, latitude, longitude from serviceappointment where appointmentnumber = 'SA-3600' limit 1];3If(!sas.isEmpty()){4 //retrieve the service territory record id from the getTerritoryIdByPolygons method using geolocation fields from the first appointment in the list5 Id ServiceTerritoryId = FSL.PolygonUtils.getTerritoryIdByPolygons(double.valueOf(sas[0].longitude),double.valueOf(sas[0].latitude));6 system.debug(ServiceTerritoryId);7}
getAllPolygonsByLatLong(longitude, latitude)
Returns a list of IDs of all matching polygons that include the point with the longitude and latitude values.
Signature
static List getAllPolygonsByLatLong(Double longitude, Double latitude)