How to enable engine snapshot and CNG master switch custom parameter to all the vehicles in the database

Related Questions

  • Apply engine snapshot and CNG master switch parameter to all vehicles

Applies To:

  • MyGeotab SDK
  • Custom Parameter
  • MyGeotab

Procedure:

  1. Go to the MyGeotab SDK API Runner
  2. Enter the server, database and your credentials to login
  3. Enter the following API call:
     
     
    /* The following JavaScript example shows how to call Authenticate. Just fill in your details for each of the parameters. */
    api.call("Get", {
    "typeName":"Device"
    }
    , function(result) {
    letenableSnapshotParameter = {
    "bytes":"QA==",
    "description":"Enable Engine Snapshot",
    "isEnabled":true,
    "offset":164
    };
     
    letenableGaseousFuelParameter = {
    "bytes":"IA==",
    "description":"Enable Gaseous Fuel Info",
    "isEnabled":true,
    "offset":167
    }
     
    varmulticallArray = [];
    vartempArray = [];
     
    for(letdeviceofresult){
    if(device.serialNumber[0] !== "C" && device.activeTo == "2050-01-01"){
    // console.log(device);
    tempArray = [];
     
    if(device.customParameters !== null){
    for(letcustomParameterofdevice.customParameters){
    // console.log(customParameter);
    tempArray.push(customParameter.description);
    }
    // console.log(tempArray)
     
    if(tempArray.indexOf("Enable Engine Snapshot") == -1){
    device.customParameters.push(enableSnapshotParameter);
    }
     
    if(tempArray.indexOf("Enable Gaseous Fuel Info") == -1){
    device.customParameters.push(enableGaseousFuelParameter);
    }
    console.log("custom",device.customParameters);
    } else {
    device.customParameters.push(enableSnapshotParameter);
    device.customParameters.push(enableGaseousFuelParameter);
    }
     
    // console.log('device before push', device)
     
    // multicallArray.push(
    // [
    api.call("Set", {
    "typeName":"Device",
    "entity":device
    }
    // ]
    ,function(success){
    console.log(`${device.serialNumber} set`);
    });
    // tempArray = [];
    // console.log(tempArray);
    }
    // console.log(device.id);
    }
    // console.log(multicallArray);
     
    // api.multiCall(multicallArray,
    // function(success){
    // console.log(success);
    // }, function(e){
    // console.log(e);
    // });
     
    }, function(e) {
    console.error("Failed:", e);
    });