Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
IainCaldwell
Lansweeper Employee
Lansweeper Employee

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 ‘Configure’

  • Expand 'CMDB Application:Lansweeper ETL

  • Click on Lansweeper ETL (under the name). This will take you to the page ‘ETL Transform Map Assistant

  • Click on item 1 ‘Import Source Data and Provide Basic Details’

  • Change the Preview Size Override to 150 (some other than the default)

sg install status 2.png

  • 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

    • Output - u_state_name_1 (note this is generated so just makes sure you update the code with the correct name if its different)

    • Input - u_state_name_1

    • Script

(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);

sg install status 3.png

  • Click Apply

    • You should see the new column populated (unfortunately group by doesn’t seem to work, so you can only base on the data you can see)

  • 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

    • Install Status

  • From the right hand side select u_state_name_1 and drag over Install Status.

sg install status 4.png

  • when happy click the left arrow to return to the Map Data to CMDB and Add Relationsips screen.

  • Mark as complete.

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.

0 REPLIES 0

General Discussions

Find answers to technical questions about Lansweeper.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now