- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2017 04:02 AM
Same code just with comments for each step to explain.
// link CI to Asset just like Assets are linked to CIs
var gr = new GlideRecord('alm_asset'); //create glide record on table
gr.query(); //query all records in table
while(gr.next()) {
var Id = gr.ci; //get sys_id for CI in alm_asset table
var cmd = new GlideRecord('cmdb_ci'); //create glide record on table
cmd.addQuery('sys_id',Id); //where sys_id from cmdb_ci == sys_id from ci on Asset table (Id)
cmd.query(); // run query
if(cmd.next()) {
cmd.asset = gr.sys_id; //update asset field on cmdb_ci table with
cmd.setWorkflow(false); //disable running of business rules that might normally be triggered by subsequent actions
cmd.update(); //commit update
}
}