Asset and Ci install status mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 11:40 AM
Hello All,
I am working in cmdb ci where when we are changing field of asset state, then Install status of ci is also changed it and vice versa.
The mapping between Asset and Ci is defined in Asset CI Install Status Mapping (alm_asset_ci_state_mapping) table. This is working fine but for some cases it is not working. When we change the asset state to Missing, install will change to Absent. But again if we change asset state to in use, install state will not change Installed... But if we change into other asset state, install state will chNge. Can any one help in this....
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 01:19 AM
You have mentioned that you were checking in cmdb_ci. In the screenshot, I can see 'State' which is part of Asset tables and not present on CMDB tables. Can you explain how the 'State' field is displayed on cmdb_ci? Is it some custom field? Also did you check whether the mismatch is there in the 'State' field of the corresponding Asset record?
In your screenshot, even the 'Hardware status' is shown as 'Retired' which is another mismatch. If there is actually a mismatch with the 'State' of the corresponding asset record, have you checked whether the OOB mapping for Asset state=In use is active in both Asset-CI install status mapping and Asset-CI hardware status mapping tables? The OOB mappings are read-only and ideally should not have got modified. If there is actually an issue with the 'State' of corresponding Asset record, I would suggest to review these mappings first and then raise a hiticket to check with ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 01:18 AM
Hello Ashok,
Thank you for your reply.
For both table , Asset-CI install status mapping and Asset-CI hardware status mapping, we have mapping i.e.
In use <--> installed. And it is working/Active also.
But when we are first changing Asset state to Missing then it was also changes to Install status or hardware status correctly.. But if we again change asset state to In use, both of install status and harware status is not changing.
The table I am using here is cmdb_ci_computer, where few of them have asset is attached. If we are changing field in Asset state , state will also change in Install Status and hardware status (script Include used here - AssetAndCISynchronizer)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 01:46 AM
Hi @ektakumari ,
Hope you are doing well.
To address the issue you're facing with the Asset and CI install status mapping, we'll need to ensure that the mapping between Asset and CI install states is consistent and reliable.
- create a business rule to handle the automatic update of the Install Status when the Asset State changes. We'll also handle the reverse case, where changing the Install Status updates the Asset State.
// Trigger: After Update
// Table: cmdb_ci
(function executeRule(current, previous /*null when async*/) {
var assetStateField = 'state'; // Adjust this based on the actual field name for asset state
var installStatusField = 'install_status'; // Adjust this based on the actual field name for install status
// Asset states and their corresponding install status
var stateToInstallStatus = {
'1': '1', // Example: In Use (Asset State) -> Installed (Install Status)
'2': '2', // Example: Missing (Asset State) -> Absent (Install Status)
// Add more mappings as needed
};
var assetState = current.getValue(assetStateField);
var correspondingInstallStatus = stateToInstallStatus[assetState];
// If the asset state has a corresponding install status, update the CI record
if (correspondingInstallStatus) {
current.setValue(installStatusField, correspondingInstallStatus);
}
// Reverse case: Update Asset State based on Install Status (if needed)
// (Implement the reverse case if necessary)
})(current, previous);
- Ensure that the Asset CI Install Status Mapping table (alm_asset_ci_state_mapping) is correctly populated with the relevant mappings between Asset and CI install states.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 01:21 AM
Hello Riya,
Thank you for your Reply.
I will try this script.