Skip to main content

I am creating routes and waypoints via apex classes. However the 'Route Type' keeps defaulting to time-based, even though Maps setting is also set to standard. 

Although not a big issue, it involves extra clicks for the user to toggle time-based off, then clicking optimize again, for the route to actually visibly display on the map. 

The workflow is that users can set their stops and reorder manually when required, and that the Maps interface should reflect those amendments. Apex classes in the org do delete the old route and create a new route whenever reordering is done, but defaults back to time-based. 

Any suggested solutions? 

Salesforce Maps - Route Type

 

@* Sales Performance Management *

 

 

#Salesforce Maps

2 respuestas
  1. 20 mar, 07:05

    Solution found: 

     

    Issue: Routes created by WeeklyRouteOptimizer were persisting as "Route Type: Time-based" instead of "Standard" in Salesforce Maps, causing "Invalid Time" errors on all stops.

    Root Cause: The route options JSON was missing required fields that Maps uses to determine route type.

    Fix: Updated route options configuration in WeeklyRouteOptimizer.cls and DailyRoutePlannerController.cls to include:

     

     

    Map<String, Object> routeOptions = new Map<String, Object>();

    routeOptions.put('DriveProfile', 'driving'); // Geographic routing mode

    // TimeBasedOptions required for Standard type (Enabled:false disables time enforcement)

    Map<String, Object> timeOptions = new Map<String, Object>();

    timeOptions.put('Start', '09:00');

    timeOptions.put('End', '17:00');

    routeOptions.put('TimeBasedOptions', timeOptions);

    routeOptions.put('Enabled', false); // Disables time constraint validation

    route.maps__Options__c = JSON.serialize(routeOptions);

    Key Insight: TimeBasedOptions with Enabled:false is required for Standard route display (counterintuitively, it signals "I understand time windows but won't enforce them").

    Result: ✅ Routes now display correctly as Standard type with proper geographic optimization. 

0/9000