Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mapping CI Operational status choices to the Asset state choices

IB98
Tera Sage

Hello, 

I hope someone can help me figure this one out. I am trying to sync the CI Operational status field to the Asset state field. Example, if Asset state is 'In stock' and substate 'Pending repair' the Operational status should be 'Non-operational'. How can I accomplish that? This shoiuld be OOB already, but I've added 2 more choices to the Operational status and need to adjust the mapping to direct to the 2 new choices. Thank you!

5 REPLIES 5

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

Hi, this is controlled in the OOB 'Update Asset fields on change' Business Rule. This BR calls the Script Include 'AssetAndCISynchronizer'. There are a couple of tables defined, that hold the fields mapping between CI and Asset, like this:

ASSET_CI_FIELD_MAPPING_TABLE : 'alm_asset_ci_field_mapping',
ASSET_BASE_CI_STATE_MAPPING_TABLE : 'alm_asset_ci_state_mapping',
ASSET_HARDWARE_CI_STATE_MAPPING_TABLE : 'alm_hardware_state_mapping',

So it must be pretty straightforward to update these tables with your new values.

 

** please mark my answer as helpful and correct if it fits your need

 

 

Thank you on your reply. This option above updates the Status - 'install status' on the cmdb_ci table. That is already in place. I need the Operational status to update when the Asset status is changed. An example would be: 

If Asset state    substate     map to operational status field choice(cmdb_ci)find_real_file.png

I am thinking of creating a Business Rule but I am not really sure how the code needs to look like. I've tried using the filter conditions and that did not work.  

 

 

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

You may create 'Before' (insert/update) business rule on 'alm_asset' table (condition: {State changes}). Then use the script like this:

(function executeRule(current, previous /*null when async*/) {

var grCi = new GlideRecord('cmdb_ci');
if (current.getValue('install_status') == 'In Transit') grCI.setValue('install_status','Pre-Allocation');
if (current.getValue('install_status') == 'Retired') grCi.setValue('install_status','Disposed');	
//and so on	

})(current, previous);

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

@Ilvana do you still need more help here, were you able to achieve your requirement?