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.

Update Reference Field in Script

mdidrikson
Kilo Contributor

Hello,

I would like to update the manufacturer field in the CMDBo to be 'Hewlett-Packard' for all records . This field is a reference field with the following information.

Table: cmdb_ci
Element: manufacturer
Type: reference
Reference: core_company

Here is my script.



var rec = new GlideRecord('cmdb_ci_computer');
rec.query();
while (rec.next()) {
rec.manufacturer = 'Hewlett-Packard'
gs.print('Record Updated ' + rec.manufacturer);
rec.update();
}

gs.print(rec.getRowCount());



Is there a way this update can be run with a script?

Thanks!

Mark Didrikson

5 REPLIES 5

mdidrikson
Kilo Contributor

Thanks Mark! That worked great!

Mark Didrikson