The Fleet Management Job 3 is a batch job and set of platform events that receives information from and syncs record information with Samsara to monitor and manage Fleet ELD information. Run this job instead of original Fleet Management Job. It is significantly faster and more efficient. The job runs continuously every 15 minutes. This document outlines the tasks completed by the job.
Only one Fleet Management Job may be enabled at one time. Before running Fleet Management Job 3, confirm that the Catena integration is not Enabled. Navigate to TMS Admin → Credentials and find the Catena card. Uncheck the Enabled field and click Save.
Configuration
TMS Admin
Before running Fleet Management Job 3, complete the following configuration setup.
Navigate to TMS Admin → Configuration, Fleet Management.
Check the Fleet Management Enabled field.
From the Fleet Management Job field select Fleet Management Job 3.
Set the Driver Log Grace Period (Days) field to control the number of days that Driver Log Entries may be updated.
Click Save.
The Fleet Management Pass Counter field on TMS Admin → Configuration, Fleet Management does not apply to Fleet Management Job 3. Platform Event actions cannot be selected individually.
Platform Cache
Errors encountered when running Fleet Management Job 3 are stored in the Platform Cache. The next time the job runs, an email is sent to the user running the batch job containing the errors.
Navigate to Setup and search for Cache.
Choose Platform Cache to view the Platform Cache setup.
Confirm all available platform cache is assigned to tms. The image below shows an org with all available platform cache assigned to tms.
Stop a running instance of the Fleet Management Job 3 by completing the following steps.
Navigate to TMS Admin → Configuration. Find the Fleet Management section.
Uncheck the Fleet Management Enabled field.
Click Save.
Transportation Profile
The Fleet Carrier Transportation Profile mileage API settings fields are used when calculating Fleet Asset distance fields. Make sure these fields are visible on the Transportation Profile Lightning Record Page and set properly.
Mileage API
Mileage API Routing
Milage API Version
Account ELD Locations
One or more TMS Account records are paired to Samsara Locations/Addresses by the Account ELD record created for every Fleet shipping locations and addresses. Before running the Fleet Management Job 3 for the first time, complete the following steps to receive and create Account ELD records from Samsara.
Navigate to TMS Admin → Configuration.
Click the ELD Location Download button at the top of the component.
A banner at the top of the component confirms that locations are downloading.
View download progress by navigating to Setup → Apex Jobs and find the FleetManagementJob Apex Class in the list.
Job Functions
The Fleet Management Job 3 runs as a combination of mostly platform events and an additional batch job. The first time the job runs in a day includes the additional batch job. All remaining runs in the day contain only the platform event actions.
TMS Broker users may use Fleet Management Job 3 to update the Timezone field for Account records. Select Emergency Run from the Job Monitor LWC to run the platform event actions.
The Fleet Management Enabled field should not be Checked when only updating Account Timezones.
Batch Job
The following actions are completed sequentially as a batch process when Fleet Management Job 3 runs the first time in a day (usually the first time the job runs after midnight). This batch process only completes once per day.
Retrieves the latest Driver Hours of Service (HOS) Driver Log and Driver Log Entry records. The period when Driver Long Entry records may be updated is defined by the Driver Log Grace Period (Days) field. By default, Driver Log Entry records for may be updated 2 days prior to the current day. This field may be changed under TMS Admin → Configuration, Fleet Management. Driver Log records are only created once the day is ended.
Driver Log and Driver Log Entries are returned from Samsara. Drivers are matched to Log and Log Entry records by the Driver Id field returned from Samsara and matched by the Driver ELD ID field.
Driver Log and Driver Log Entry records are matched to existing records or new records are created in the TMS.
When Driver Log or Driver Log Entry records exist in the TMS and match records from Samsara, the records are updated with values received from Samsara.
The Samsara values are not added to existing fields or rolled-up when updating TMS records. The values received from Samsara overwrite the existing values.
When Driver Log or Driver Log Entry records do not match any existing TMS records, new records are created in the TMS.
One Driver Log record is created for each day and named the “Driver Name - Date.” Example: “Joe Driver - 2024-09-30.”
Samsara may populate multiple Driver Log Entry records to a single Driver Log record.
A driver may create additional Log Entries on a date for a Driver Log record that already exists.
These additional log entries are passed from Samsara to the TMS and added to the existing Driver Log Record as an additional Driver Log Entry.
When a Driver Log Entry is added or updated, any obsolete Driver Log Entry records are deleted as part of the next action. Driver Log Entry records can only be updated during the Driver Log Grace Period.
Driver Log records are never created for the current day.
Deletes obsolete Driver Log Entry records from the TMS. Any Log Entry records within the Driver Log Grace Period and do not match to the Driver Log records received are deleted. Driver Log Entries outside of the Driver Log Grace Period are not deleted. This action does not delete Driver Log records.
Record Delete example: While in the Driver Log Grade Period, a driver updates a log entry from 2 days prior. The driver updates the off duty time from 7:00 pm to 6:15 pm. During the next run, the updated entry is received by the TMS. A new Driver Log Entry record is created for the appropriate Driver Log. The original 7:00 pm record entry is deleted as it does not match the received Log or Entry.
Platform Events
The following actions are completed each time the job runs as several platform events.
Sets the Timezone for all Account shipping locations (1000 max records updated per pass).
When Fleet Management Enabled is not Checked this process runs to populate the Account Timezone field.
All shipping locations without a time zone but have the Shipping Postal Code and Shipping Latitude fields populated are eligible to update.
The Addrexx integration matches Account addresses. Addrexx requires addresses have a Country value paired with either a City or Postal Code. Addresses without a Country value generate an error message that is sent via email.
Addresses returned from Addrexx are matched to Account locations. Addresses must match on City, State, and the Time Zone must match the Salesforce Time Zone picklist value. If no match is found, the Timezone is set to Unknown. Manually set any Timezone fields that are not set.
When a match is made, the Account timezone is set to the time zone returned from Addrexx.
A maximum of 1000 Account records are updated each time the job runs. The job likely needs to run several times to set the Timezone on all Account records.
If an Account Timezone field cannot be updated due to custom code or validations, this pass of the batch process is disabled. The Timezone Update Disabled field is set to Checked.
The Timezone Update Disabled field is set on TMS Admin → Configuration, Fleet Management. Correct any errors preventing Account record updates before setting this field to Unchecked.
Samsara Vehicles are synced with Fleet Asset records via the ELD ID field. This match is initially established by matching the VIN field.
Do not create Fleet Assets in the TMS first. These records are not sent to Samsara.
Samsara Vehicles are sorted for creating or updating records in the TMS. The VIN and ELD Id fields in Samsara and the TMS are compared to determine if the record exists in the TMS.
When a Samsara vehicle does not exist in the TMS, a Fleet Asset record is created.
The following fields populated for the TMS Fleet Asset record.
Name
Company/Division
ELD Model Number
ELD ID
ELD Serial Number
License Plate Number
VIN
Year
The TMS sets the following fields.
The Company/Division field is set to the Fleet Management Default Carrier under TMS Admin → Configuration, Fleet Management.
The Status field is set to Available.
The Type field is set to Tractor.
If a Fleet Asset record matches an Samsara record by VIN, no new record is created.
When the VIN matches, but the ELD Id does not, the following TMS Fleet Asset fields are updated with Samsara values.
ELD ID
ELD Serial Number
When a single TMS Fleet Asset record matches two separate Samsara vehicles by VIN, the following occurs.
An error email is sent to the User that ran the job and lists the Fleet Asset records with duplicate VIN fields.
Correct these duplication errors as necessary.
Update the Fleet Asset Name and/or License Plate Number fields in the TMS as necessary.
Changes made to these fields are sent to Samsara and are updated accordingly.
Gets and saves the latest Fleet Asset statistics. The following fields are updated with values received from Samara.
Ambient Air Temperature (C)
Barometric Pressure (PSI)
Battery Voltage
ELD Last Update
Engine Coolant Temperature (C)
Engine RPM
Engine State
Fuel Percent Remaining
Geolocation Latitude
Geolocation Longitude
Last Odometer Reading
Last Odometer Reading Date
Odometer Unit
Samsara Drivers are synced with TMS Driver records by the ELD ID field. This pairing is set by matching the ELD ID, CDL # and CDL State/Province, and Username fields.
Drivers are returned from Samsara and matched to existing TMS Driver records.
Drivers that only exist in the TMS (no matches) and have the ELD Enabled field Checked are sent to Samsara.
The following Driver fields are sent to Samsara for Driver creation.
Activation Status
Adverse Weather ELD Exemption
Big Day ELD Exemption
CDL #
CDL State/Province
Driver Name
ELD Day Start Hour
ELD Exempt
ELD Exempt Reason
Password
Personal Conveyance Duty Status
Phone
Timezone
Username
Yard Move Duty Status
Driver Ruleset Override (when Checked the following fields are included).
Cycle Override
Restart Override
Rest Break Override
Jurisdiction Override
Drivers are sorted for record syncing. Samsara and TMS Driver records are matched based on 2 separate criteria: ELD ID and 2 License fields.
The Samsara ELD Id matches the TMS Driver ELD ID field.
The following Driver fields are compared. Any mismatches are sent sent from the TMS to update the Driver record in Samsara.
Activation Status
Adverse Weather ELD Exemption
Big Day ELD Exemption
CDL #
CDL State/Province
Driver Name
ELD Day Start Hour
ELD Exempt
ELD Exempt Reason
Password
Personal Conveyance Duty Status
Phone
Timezone
Username
Yard Move Duty Status
Driver Ruleset Override (when Checked the following fields are included).
Cycle Override
Restart Override
Rest Break Override
Jurisdiction Override
When the Samsara and TMS Driver License Number and License State fields match, the following happens.
The TMS Driver ELD ID field is updated to match the Samsara value.
The following TMS Driver fields are compared. Any mismatches are sent sent from the TMS to update the Driver in Samsara.
Activation Status
Adverse Weather ELD Exemption
Big Day ELD Exemption
CDL #
CDL State/Province
Driver Name
ELD Day Start Hour
ELD Exempt
ELD Exempt Reason
Password
Personal Conveyance Duty Status
Phone
Timezone
Username
Yard Move Duty Status
Driver Ruleset Override (when Checked the following fields are included).
Cycle Override
Restart Override
Rest Break Override
Jurisdiction Override
When the Samsara username field matches the TMS Driver Username, the following happens.
The TMS Driver ELD ID field is updated to the Samsara value.
The following Driver fields are compared. Any mismatches are sent sent from the TMS to update the Driver record in Samsara.
Activation Status
Adverse Weather ELD Exemption
Big Day ELD Exemption
CDL #
CDL State/Province
Driver Name
ELD Day Start Hour
ELD Exempt
ELD Exempt Reason
Password
Personal Conveyance Duty Status
Phone
Timezone
Username
Yard Move Duty Status
Driver Ruleset Override (when Checked the following fields are included).
Cycle Override
Restart Override
Rest Break Override
Jurisdiction Override
Drivers that only exist in Samara (no matches) are created in the TMS.
TMS Contact records are searched for any Driver names that only exist in Samsara. If no record exists, a new Contact is created for the Driver.
The Contact Name field is the Driver Name.
The Contact Account Name field is set to the Account associated with the Fleet. If the Account does not exist in the TMS, the Fleet Management Default Carrier populates the field. The Fleet Management Default Carrier is set under TMS Admin → Configuration, Fleet Management.
The Contact Transportation Role is set to Driver.
If a TMS Contact record exists associated with no Driver, the new Driver record Email and Phone fields are populated from the Contact record.
The Driver Type field is set to Employee when the following occurs.
When the Driver Type field does not have a value AND;
The Contact Account Name field is associated with the Fleet or the Fleet Management Default Carrier. The Fleet Management Default Carrier is set under TMS Admin → Configuration, Fleet Management.
The Driver Type field is set to Independent Contractor when the following occurs.
When the Driver Type field does not have a value AND;
The Contact Account Name field is NOT associated with the Fleet or the Fleet Management Default Carrier. The Fleet Management Default Carrier is set under TMS Admin → Configuration, Fleet Management.
The Driver Phone updates the corresponding Contact record Phone.
Use caution when creating Driver records in the TMS. Driver records cannot be deleted once sent to Samsara.
Gets and Saves the Driver Hours of Service Clocks.
Samsara Drivers are matched to TMS Drivers. The following TMS Driver fields are updated from Samsara.
Current Duty Status
Cycle Started
Cycle Time Remaining
Cycle Time Remaining Tomorrow
Cycle Violation Duration
Drive Time Remaining
Shift Driving Violation Duration
Shift Time Remaining
Time Until Break
The TMS does no calculations to determine these values.
Gets and saves all messages associated with a Driver in the TMS. Only new messages are saved since the last time the job ran.
A Start Date and End Date are passed to Samsara to define a period based on the last time the Fleet Management Job 3 ran. The Start Date is the date and time from the last run of the job. The End Date is now.
Messages with a Sender Name of “Dispatch” are ignored. These messages are sent from Samsara to the Driver.
Messages are linked to a Driver by the Driver ELD ID field.
Each message has “From Driver, Load + [Load Name]” added to the beginning of the message.
Messages are saved to the Driver’s chatter feed.
If a Driver sends a text message and the current Load for that Driver cannot be determined, the message is dropped and not saved.
Gets and saves all documents associated with a Driver in the TMS. Only new documents are saved since the last time the job ran.
A Start Date and End Date are passed to Samsara to define a period based on the last time the Fleet Management Job 3 ran. The Start Date is the date and time from the last run of the job. The End Date is now.
Documents are linked to a Driver by the Driver Id field. If a Driver is associated with a Load, the document is attached to the Load record. If a Driver is not associated with a Load, an Inbound Email record is created.
The subject contains “The driver document could not be associated with a Load.”
The “From” email address is the Driver Contact record email.
Drivers must submit all documents from the Samsara phone application from the route the document is associated with. Otherwise it cannot be associated with the load.
Syncs Account TMS Type Shipper/Consignee locations used by new Stops.
Get Load, Stop, and Trip Plan updates for all active Routes.
Samsara Driver Routes are paired with Fleet Assignment records via the ELD Route ID field.
Updates the current location of a Load based on the Fleet Asset Geolocation.
Geolocations are requested for each Fleet Asset. If the Geolocation field changes from the previous time the job ran, then the ELD Last Update field also updates.
Fleet Assets are matched by the ELD ID received from Samsara.
Job Monitor LWC
The Batch Process Monitor may be used to run Fleet Management Job 3 and also perform an Emergency Run of the job. View Batch Process information for more specific functionality.
Select Run Now to initialize the job. The job schedules itself to run again when it completes.
Choose Emergency Run to initialize only the platform event actions portion of Fleet Management Job 3. Choosing Emergency Run skips the Salesforce batch process architecture and runs the platform events immediately. This action should only be used when experiencing issues with the Salesforce batch scheduler. Typically, issues requiring an Emergency Run may arise when trying to run multiple other batch processes.