How to set CI active=false

patk1000
Giga Contributor

I have to be missing something incredibly simple here. I can run a glide record query for active=true:

var rec = new GlideRecord('cmdb_ci');

rec.addQuery('active',true);

rec.addQuery('name', 'foobarbaz');

rec.query();

while(rec.next()){

      gs.print(rec.sys_id);

      gs.print(rec.name);

}

...Yet when I want to set active=false, there doesn't appear to be an attribute on the record, nor a column in the cmdb_ci table that I can set.

Questions:

1. What the heck am I missing?

2. Am I completely off my rocker to want to set a CI to active=false? Maybe I'm violating some core ITIL principle?

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

Active is not an oob field on the cmdb_ci table. Most use the Status field.


View solution in original post

7 REPLIES 7

Michael Fry1
Kilo Patron

Active is not an oob field on the cmdb_ci table. Most use the Status field.


Ahh, its the silent failure of us "thinking" we're querying on active (since records are being returned), but there's actually no field on the records.


Mike Allen
Mega Sage

I think it ignores that line.   There is no active field on cmdb.   I have had to add it everywhere I have worked, and have often asked myself this question.   Setting a CI to inactive seems logical to me, too.


rob_blakey
Tera Expert

Hi Pat,



Change your script to something like:



  1. var rec = new GlideRecord('cmdb_ci');  
  2. rec.addQuery('install_status',Installed);  
  3. rec.addQuery('name', 'foobarbaz');  
  4. rec.query();  
  5. while(rec.next()){  
  6.       gs.print(rec.sys_id);  
  7.       gs.print(rec.name);  
  8. }

PrtScr capture_17.jpg