Ci to Asset State Sync
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 11:00 AM
Hello everyone,
I am having issues with asset state not updating when the CI hardware status is installed, I need the asset status to change to in use. It appears there is mapping in place that requires the status to be installed with a substatus of in use on the CI for it to change the asset state to In use. Can anyone guide me how to get the CI substatus to be in use when the status is installed or just have the asset state update to in use when the CI status is installed? Any help would be much appreciated!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 11:53 AM
Hi @jonsr20 ,
the OOB AssetAndCISynchronizer Script Include could be customized to piggy-back the additional field change on the insert/update already being done by the 'Create CI on insert' or 'Update CI fields on change' Business Rules.
Creating a Business Rule on the asset to update the CI is not advised, as this usually leads to nested updates and recursion, as the other OOB business rules in relation to Asset to CI synchronization will already be making updates at the same time.
Below is the recommended change for the AssetAndCISynchronizer Script Include to give precedence to one column over the other. By default, if a CI is of type Hardware, hardware_status (Hardware status) and hardware_substatus (Substatus) fields are given precedence over install_status (Status) field.
Current API code:
_inferAssetStatuses : function(ci, asset, asyncUpdate) {
// HW statuses take precedence over CI statuses
if (this._isHardwareCI(ci)) {
if (!ci.hardware_status.changes() && !ci.hardware_substatus.changes() && !asyncUpdate)
return 0;
return this._inferAssetStatusesHardware(ci, asset);
} else {
if (!ci.install_status.changes() && !asyncUpdate)
return 0;
return this._inferAssetStatusesBase(ci, asset);
}
},
Change the code to:
_inferAssetStatuses : function(ci, asset, asyncUpdate) {
var precedenceColumn = "install_status"; //Value can be either "install_status" or "hardware_status"
// HW statuses take precedence over CI statuses
if (this._isHardwareCI(ci) && precedenceColumn === "hardware_status") {
if (!ci.hardware_status.changes() && !ci.hardware_substatus.changes() && !asyncUpdate)
return 0;
return this._inferAssetStatusesHardware(ci, asset);
} else {
if (!ci.install_status.changes() && !asyncUpdate)
return 0;
return this._inferAssetStatusesBase(ci, asset);
}
},
Below are the different mappings between status fields:
- Asset to CI
- Asset to Hardware
- CI to Asset
- Hardware to Asset
Please refer to below thread:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717902
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 12:16 PM
So, I want the CI to update the Asset when the CI hardware status is installed, I need the Asset state to change to In Use. I am pretty new to this and having trouble locating the AssetAndCISynchronizer script. The above script will accomplish changing the asset state to In Use when the CI hardware status is installed? Apologies I am still learning and pretty new at this, your help is greatly appreciated if you can point me where the assetandcisyncrhonizer script is located.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 05:02 AM
Hello @jonsr20 ,
Try to access this table : alm_asset_ci_state_mapping
alm_hardware_state_mapping
In the left navigator type the tablename.LIST
Hope this helps.
Thanks
Amarjeet Pal
Dont forget to Hit Helpful button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 05:59 AM
Thank you for the assistance I actually got this working with a modification to a Pre/Post Script and a business rule to change Asset state to In Use when hardware status is installed and substate is In Use.