
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 12:21 AM
Can someone please help me here?
We have manually imported CI and Assets into CMDB. This was done at two separate occasions. First we imported the CIs without relation to an Asset and then we imported the Assets that had relation to CIs.
This resulted in that I can see relating CI from an Asset, but not relating Asset from a CI. Now I need to relate the ~10 000 CIs with the once that have an Asset. How can this be done?
Anyone that can help out with a background script on this?
I did take a look on this page:
I know there are some business rules that run in the background when creating Assets or CI.
- Update CI fields on change (on the Asset [alm_asset] table)
- Update Assets on change (on the Configuration Item [cmdb_ci] table)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 03:17 AM
HI Henrik,
Now what you have to do is write a one time script.
You will have to query on asset able and take value of CI field and then query CI table and update Asset field on CI Table.
See below script:
var gr = new GlideRecord('alm_asset');
gr.query();
while(gr.next())
{
var Id = gr.ci;
var cmd = new GlideRecord('cmdb_ci');
cmd.addQuery('sys_id',Id);
cmd.query();
if(cmd.next())
{
cmd.asset = gr.sys_id;
cmd.setWorkflow(false);
cmd.update();
}
}
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 12:56 AM
Hi Henrik,
I have one question. Please help me through this.
What do you mean when you say you have link from CI to Asset and not from Asset to CI.
How you imported asset CI relation ship.
Thank you,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 03:10 AM
Please look at my comment to David below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 01:44 AM
This resulted in that I can see relating CI from an Asset, but not relating Asset from a CI. Now I need to relate the ~10 000 CIs with the once that have an Asset. How can this be done?
I understood it to be the other way around: models create the relationships between assets and CIs, but they're a definition attached to an asset that determines if a CI will be related or not, and how changes should propagate.
The process should have been:
- define models for the assets, along with the relationships
- import assets, letting them create CIs
- import CIs, letting them update CI attributes
It sounds like you've done 2 and 3 in isolation and are now seeking to manually redo the work that models will have done for you back at stage 1.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 03:06 AM