1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ServiceNowのGlideRecordでReference項目をdot walkする

Last updated at Posted at 2022-12-11

こういう書き方が出来ると最近知りましたIncidentのReference項目をdot walkしています

var gr_i = new GlideRecord("incident");
gr_i.query();
while (gr_i.next()) {
  gs.info(gr_i.number);
  gs.info(gr_i.short_description);
  gs.info(gr_i.cmdb_ci.name); // dot walk
  gs.info(gr_i.cmdb_ci.company.name); //dot walk x2
}

今までこんな書き方してたのですが。。。だいぶ楽に書けました(内部的に同じような処理が走ってるかもですが見た目もすっきりです)

var gr_i = new GlideRecord("incident");
gr_i.query();
while (gr_i.next()) {
  gs.info(gr_i.number);
  gs.info(gr_i.short_description);
  var gr_c = new GlideRecord("cmdb_ci");
  gr_c.get(gr_i.cmdb_ci);
  gs.info(gr_c.name);
  var grc_cc = new GlideRecord("core_company");
  grc_cc.get(gr_c.company);
  gs.info(grc_cc.name);
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?