- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 06:56 AM
Hello everyone,
In our project we have imported the product models and prepared model categories and now we are importing CIs into cmdb_ci table (the root one, without any class).
I tried to create model category which would link cmdb_ci and alm_asset but CI class field does not accept the cmdb_ci table. Is it possible to work around it, so that if there is any new record in the cmdb_ci there is also a new record referenced in alm_asset?
It works with any other cmdb_ci table, but not the root one.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 08:50 AM
We should never create assets for everything populated in cmdb_ci. All CIs are not assets. That is why asset creation should be controlled using the relevant model category or model records as per ServiceNow best practices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 07:46 AM
Hello @mateuszgrzeskow
You need to create a Flow Designer for this requiremernt.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 08:15 AM
If you want to write script then you can use the following (function() {
var cmdbCi = current; // Get the new cmdb_ci record
// Create a new alm_asset record
var almAsset = new GlideRecord('alm_asset');
almAsset.initialize(); // Initialize the record
// Set the fields in the alm_asset record based on cmdb_ci
almAsset.name = cmdbCi.name; // Set the name field
almAsset.description = cmdbCi.description; // Set the description field
// Set other fields as needed
// Insert the alm_asset record
var almAssetSysId = almAsset.insert();
gs.info("New alm_asset record created with sys_id: " + almAssetSysId);
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 08:50 AM
We should never create assets for everything populated in cmdb_ci. All CIs are not assets. That is why asset creation should be controlled using the relevant model category or model records as per ServiceNow best practices.