Change field that discovery updates for location?

Conan_Lloyd
Mega Expert

For reasons I can't go into we need discovery to no longer update the location field but update a new field called Discovered Location u_discovered_location.   I can't find the script I need to update.   Can anyone help me out?

1 ACCEPTED SOLUTION

prdelong
Kilo Guru

If you don't want to modify the Shazzam probe, you can also put an "after" business rule on the 'discovery_device_history' table. It holds the CI in a reference field and you can dot-walk to the Discovery Schedule table. Of course that doesn't prevent the location form being written to the location field on the CI record, but I know a lot of clients have been hesitant to modify the OOB probes/sensors. You can set the location record to NULL and erase that value if you want though (or write another BR to reject any update to the location field).



conditions: !current.cmdb_ci.nil() && current.cmdb_ci.changs()



addLoc();



addLoc(){



var sysID = current.cmdb_ci;



var newLoc = new GlideRecord('cmdb_ci_hardware');


newLoc.addQuery('sys_id',sysID);


newLoc.query();



if(newLoc.next()){


        //gs.log("Location name is: " + current.status.dscheduler.location);


        newLoc.u_discovered_location = current.status.dscheduler.location;


        //newLoc.location = NULL;


        newLoc.update();


}



View solution in original post

7 REPLIES 7

I wouldn't, but it all depends on what field you are trying to prevent from being updated. That's something that is likely bettered handled at the probe/sensor level.


Conan_Lloyd
Mega Expert

This worked perfectly, thank you!!


sunilsafare
Mega Guru

ok Thanks for the info prdelong.