How do I connect imported assets with contracts in an import set

Robin Chadwick
Kilo Contributor

I have a spreadsheet of hardware assets that I need to import.  Each of the assets is related to a contract that exists in the contracts table.  I have the contract number included in the hardware asset import spreadsheet for each asset.

How do I import the assets into the table [alm_hardware] and connect each asset to its corresponding contract through the import.  

I am not interested in adding the contract to each asset manually as there is over 3500 assets.  Also, I am not interested in adding the assets to the contracts manually as there is over 3500 assets.  

I'm looking for how to do this with an import set and transform map.

Here is some example data

find_real_file.png

1 ACCEPTED SOLUTION

Abdul Khan4
Kilo Guru

Hi Robin, is this solution works for you? If yes, please accept the solution.

View solution in original post

7 REPLIES 7

Abdul Khan4
Kilo Guru

On alm_hardware table, Create a Field called Contract and reference this field with Contract Table. Now when ever you do import, MAP this new field on with the contract data field in the data source. When you do upload, all contract records will be linked as required.

Robin Chadwick
Kilo Contributor

Thank you for replying.  I'm afraid that's not what I'm looking for.

Hardware Assets already have a Contracts tab where you can manually associate a hardware asset to a contract.  The relationship between hardware assets and contracts can be 1 to many, so a reference field doesn't cut it.

find_real_file.png

What I need to know is what do I need to do in the import set or the transform maps to get the contracts populated in the asset record when I do the import? 

 

 

Abdul Khan4
Kilo Guru

Two Options you can do (with code and without code)

 

1. Write a code in existing transformation MAP to make entry of Asset name (Created after import) and Contract in "clm_m2m_contract_asset" table.

onAfter

When: The onAfter event script is processed at the end of a row transformation, after the source row has been transformed into the target row and saved.

https://docs.servicenow.com/bundle/jakarta-platform-administration/page/script/server-scripting/reference/r_MapWithTransformationEventScripts.html

 

2. MAP Comments field of Hardware table to have Contract data and Upload all data in Hardware table

Once all data get uploaded in Hardware table, personalize table list view and select only Asset Name and Comment. Now download all records with Asset Name and Comments (having contract information).

Again upload this data into clm_m2m_contract_asset table.

find_real_file.png

Abdul Khan4
Kilo Guru

Hi Robin, is this solution works for you? If yes, please accept the solution.