How Can I Determine if a Driver is Historical Using the SDK?

Applies To

  • MyGeotab SDK
  • Historical user
  • activeTo

Answer

The User object in our SDK has an activeTo field, and this can be pulled using any of our APIs.  If a driver is historical, their activeTo date will be a past date.

If you would like to pull only currently active users, you can include the current datetime as the fromDate in a UserSearch

The following pulls all historical drivers from a database:

api.call("Get", {
"typeName": "User",
}, function(results) {
let historicalDrivers = [];
for (var result of results){
if (result.isDriver === true && result.activeTo < new Date().toISOString())
historicalDrivers.push(result);
}
console.log("Done: ", historicalDrivers);
}, function(e) {
console.error("Failed:", e);
});

Additional Notes

You can find more on this field on our SDK reference page.