【问题标题】:What is the meaning of this code in service now?现在服务中的这段代码是什么意思?
【发布时间】:2020-05-07 18:45:16
【问题描述】:

我在 Server Now 中使用我的请求小部件。 有这行代码。

    var notClosedResolved = 'stateNOT IN6,7';
    var closedResolved = 'stateIN6,7';

这是什么意思?

请帮忙 提前致谢

【问题讨论】:

  • variables 都是 assigned string 值。这就是我很确定的全部
  • 这些字符串值的含义取决于使用它们的上下文,未指定。
  • 这些很可能是 SQL 查询的片段。您可以查看此内容以了解它们在 ServiceNow 中的使用方式:community.servicenow.com/…

标签: javascript servicenow


【解决方案1】:

这是一个编码查询。默认情况下,状态 6/7 是存储在 ServiceNow 中的状态的数值。

所以“已解决”和“已关闭”是“显示”值(最终用户看到的),6/7 是这些显示值后面的数值,以便在开发时更容易访问。

实际上,notClosedResolved/closedResolved 表示在进行某种形式的查询时将使用它们。

例如:

//The two variables storing the encoded queries.

var notClosedResolved = 'stateNOT IN6,7';;
var closedResolved = 'stateIN6, 7';

//The query being added to the GlideRecord, then queried.
var gr = new GlideRecord('incident');
gr.addEncodedQuery(notClosedResolved);
gr.query();

//If any tickets matching the query (Not closed or resolved) exist, then do whatever is in the while and update the record
while(gr.next()){
    gr.short_description = 'Example - All non-closed/resolved incidents';
    gr.update();
}

//The query being added to the GlideRecord, then queried.
var gr = new GlideRecord('incident');
gr.addEncodedQuery(closedResolved);
gr.query();

//If any tickets matching the query (Closed or resolved) exist, then do whatever is in the while and update the record
while(gr.next()){
    gr.short_description = 'Example - All closed/resolved incidents';
    gr.update();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 2018-01-23
    相关资源
    最近更新 更多