lookupVINS
lookupVINS Method
Description
Decodes “VIN” fields in vehicle data to extract the fields “Type”, “Year”, “Make”, “Model”, and “TypeId”. The extracted vehicle information can be used to update the vehicle data. See example below.
.lookupVINs(/* Object */ vehicleData, /* Function */ onSuccess, /* Function */ onError)
Remarks
Collects any VINs from the supplied vehicle data, then makes requests to the NHTSA VIN webservice to decode them. It then updates the fields “Type”, “Year”, “Make”, “Model”, and “TypeId” for each vehicle with the data from the vehicle’s VIN and returns the resulting vehicle data via the provided success function.
Parameters
vehicleData
Object
An object containing vehicle data. See the vehicleData property for more information.
onSuccess
Function
This function will be called if the request completes successfully. It will be passed one parameter, the resulting vehicleData object.
onError
Function
A function that accepts one parameter, an Error object. This function will be called if the method does not complete successfully. The passed Error object indicates the nature of the failure.
Example
editor = new window.__editor(undefined, document.getElementById('editor-node'));
/* set editor properties here */
editor.startup();
// Set sample case-specific vehicles with VIN decoding.
editor.lookupVINs(
{
vehicles: [
{ "label": "Unit 1", "data": [
{name: "VIN", value: "1G1YW2DW0A1JB9MJ9", show: true},
{name: "Color", value: "green", show: false}
]},
{ "label": "Unit 2", "data": [
{name: "VIN", value: "JN1BZ36D69L7HLX6H", show: true},
{name: "Color", value: "silver", show: false}
]},
{ "label": "Unit 3", "data": [
{name: "VIN", value: "4S6CK58W12U4HNUEM", show: true},
{name: "Color", value: "black", show: false}
]}
]
},
function(result) { editor.set("vehicleData", result);},
function(err) { console.log(err);}
);