Hi.
I was asked a couple of weeks ago if the Lansweeper state was mapped against the ServiceNow install status when using our Service Graph connector. I have to admit that i hadn't really looked previously (i'd checked user, location, department mapping....but not the state).
Given by nature I'm curious about 'stuff' when i looked and realised we didn't map out of box I decided to have a go. So here are my notes to help guide.
Firstly, I'll give you the mapping I decided to go with, then I'll give you the steps to try it yourself (along with the little script I had to use to do the mapping....note we aren't supporting the script...you use it at your own risk.....I might be app dev certified but I've not done much hands on keyboard programing for a very long time)..
Mapping - I went with this
ServiceNow Install Status - Label | ServiceNow Value | Lansweeper State |
Absent | 100 | |
In Maintenance | 3 | Broken |
In Stock | 6 | Stock, Spare |
Installed | 1 | Active |
On Order | 2 | |
Pending Install | 4 | |
Pending Repair | 5 | In Repair |
Retired | 7 | Non-active |
Stolen | 8 | Stolen |
I didn't map 'Dont Show'....as its really not a status/state and i didn't map in 'Sold', but i guess i could have just picked 'Retired'.
Steps
Step 1
In order to edit the mapping you need to do it via the Lansweeper guided setup for the integration within ServiceNow. You'll need to go to
- Section 4 of the guided setup 'Mapping Configuration and Execution'.
- ETL Configuration
Step 2 - Provide Basic Information for the ETL Transform Map
We are going to need to set up the basic information for the ETL Transform Map, so when you are at the ETL Configuration section of Section 4.

Select Save.
Mark as complete
Step 3 - Create the Transform Map
On return to ETL Transform Map Assistant page select
item 2 ‘Preview and Prepare Data’.
Do a search on state (normal browser search page) to find u_state_name (or search u_state_name).
Click the hamburger menu next to the column label and select create new transform.
Select ‘Multiple Input/Output Script’ from the options
Ensure the following values are correct
(function(batch, output) {
for (var i = 0; i < batch.length; i++) {
var input = batch[i].input; // Value of the input columns concatenated with '|'.
// Access input column values by their names, ex: batch[i].column_name
// In order to access columns containing multiple parts concatenated by a dot, use bracket notation ex. batch[i]['prefix_name.column_name']
// Add your code here.
// Access the u_state_name column value
var stateName = batch[i].u_state_name;
// Transform the value based on the specified conditions
// ServiceNow Install status, Absent (100), In Maintenance (3), In Stock (6), Installed (1), On Order (2), Pending Install (4), Pending Repair (5) Retired (7), Stolen (8)
var transformedStateName;
switch (stateName) {
case 'Active':
transformedStateName = 1;
break;
case 'Broken':
transformedStateName = 3;
break;
case 'Stock':
transformedStateName = 6;
break;
case 'Spare':
transformedStateName = 6;
break;
case 'In Repair':
transformedStateName = 5;
break;
case 'Non-active':
transformedStateName = 7;
break;
case 'Stolen':
transformedStateName = 8;
break;
default:
transformedStateName = stateName; // Keep the original value if no match
}
// Set the output column value
output[i].u_state_name_1 = transformedStateName;
// Set each output element below, accessing output column values by their names
//output[i].column_name = output_variable_name;
}
})(batch, output);

Click Apply
Mark as complete
Step 4 - Add the field to the Mapping
Back in the ETL Configuration section 3 select ‘Map Data to CMDB and Add Relationships’.
You ideally want to add this mapping for each data mapping; however, you may decide that you only really care about a few of them, e.g., end-user devices.
Select Add Attribute
From the right hand side select u_state_name_1 and drag over Install Status.

Finish
Once all the classes to which we want to apply the attribute to are mapped, then a new run of the load ‘execute lansweper’.
Let me know if this helps. Hopefully I've managed to get the steps at the right level to follow and understand.