How can I set the Status of CIs created by Discovery on Insert? The CIs created by other sources should remain unaffected.

mkhan123
Kilo Contributor

How can I set the Status of CIs created by Discovery on Insert? The CIs created by other sources should remain unaffected.

10 REPLIES 10

Michael Fry1
Kilo Patron

CI   Classifications > open a classification >in the On Classification script, you can use 'current' to set the status. Something like current.install_status = '3';


robpickering
ServiceNow Employee
ServiceNow Employee

Asad.



Not sure if this is what you're looking for, as you don't discuss why you're looking to do this...but:



"discovery_source" is a field on the CI that should tell you how the CI was discovered.  


You could write an "on insert" Business Rule that required the discovery_source to be "ServiceNow" and then take whatever actions you'd like.   That should then only run if the CI is inserted and was discovered by ServiceNow.



If you provide more context around your use case, I may be able to expound further.



-Rob


Hi Rob,



As part of a requirement from CMDB team, we have been asked to set the Status of CIs created by Discovery to "New" (one of the choices). We also have a default Status value which Discovery uses to set the Status field while inserting the CI record.


Using the "discovery_source" field would not give accurate results since this field also has value of "ServiceNow" for some records which are not created by Discovery. Hence, can't use this solution.


I've tried creating an insert/update business rule on discovery_device_history table as follows, but this didn't trigger.


Condition: last_state == 'Created CI'


Script:


var gr = new GlideRecord('cmdb_ci');


if(gr.get(current.cmdb_ci)) {


gr.install_status = '13';


}


doug_schulze
ServiceNow Employee
ServiceNow Employee

Simple business rule; before insert that sets your chosen field to the state of new based on the role of the inserter 'midserver'.   We covered this situation in depth at Knowledge so if you have access take a look at the Discovery 301 Lab I wrote and will walk you through the entire CI Lifecycle from insert to retirement..