立即服务更新()

时间:2015-06-19 14:35:02

标签: servicenow

我希望在事件状态关闭时更新问题状态为关闭

我尝试了这段代码,但它正在更新问题表中的所有记录,但我只想更新相关的表。

// update the state of all active incidents to 4 - "Awaiting User Info"
var gr = new GlideRecord('incident')
gr.addQuery('active', true);
gr.query();
gr.state = 4;
gr.updateMultiple();

1 个答案:

答案 0 :(得分:4)

听起来你可以使用一点滑行脚本帮助。尝试更像这样的东西:

// update the state of all active incidents to 4 - "Awaiting User Info"
var gr = new GlideRecord('incident'); //Create the glide record
gr.addQuery('sys_id', current.incident_ref_field); //Only the relevant record should be returned.
gr.query();
if (gr.next()) {
    gr.state = 4;
    gr.update();
}

您只需要一个相关的inc记录,因此我们确保返回的记录与ref字段中的记录匹配(我称之为incident_ref_field,但您应该更改为实际的字段名称)。