- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2018 12:41 AM
Hi Developers,
I have a requirement to delete assets for some specific Model Categories but the associated CIs with the assets should not be deleted.
I can see "Delete asset only" UI action on "alm_hardware" table but we have to delete a lot of records so its impossible to go in every records and delete that manually.
I tried to delete that by a Scheduled Job but checked that CIs are also deleting with it.
Here is my script
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('model.sys_id=42819a63db8da3c055077608f49619b3'); // product model sys_id
gr.query();
while (gr.next()){
gr.deleteMultiple();
}
Can anyone please help me with the script where CIs should not be impacted while deleting the assets. Any help would be appreciated.
Regards,
Sreeja
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2018 01:28 AM
Go to cmdb_ci dictonary and open Asset field, then add Reference cascade rule field to the dictionary view, its default value should be Delete, change it to None temporarily and save it.
Delete the necessary assets and change Reference cascade rule to Delete again afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2018 01:28 AM
Go to cmdb_ci dictonary and open Asset field, then add Reference cascade rule field to the dictionary view, its default value should be Delete, change it to None temporarily and save it.
Delete the necessary assets and change Reference cascade rule to Delete again afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 01:07 AM
Hi Joaof,
Thanks for your response. I tried to edit the reference cascade rule on cmdb_ci table but it redirects me to CMDB table. Should I proceed with it?
Regards,
Sreeja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 02:23 AM