码迷,mamicode.com
首页 > 其他好文 > 详细

Querying Service Catalog Tables

时间:2020-04-07 22:48:37      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:catalog   情况下   walk   val   record   ice   code   查询条件   pre   

ServiceNow开发中我们在写代码查询request_item表时,经常会遇到想要根据variable的值来作为查询条件。但是官方文档有强调:

You cannot directly query the variables of the Service Catalog Request Item table [screqitem]. Instead, query the Variable Ownership table, [scitemoptionmtom], by adding two queries, one for the variable name and another for the value. The query returns the many-to-many relationship, which you can dot-walk to the requested item.

Wrong example:

var gr = new GlideRecord(‘sc_req_item‘);
gr.addQuery(‘variables.variable_iem‘,item_value);
......

Right example:

var request_item_id;
var gr = new GlideRecord(‘sc_item_option_mtom‘);
gr.addQuery(‘sc_item_option.item_option_new.name‘,‘item_name‘);
gr.addQuery(‘sc_item_option.value‘,‘item_value‘);
gr.query();

while(gr.next()) {
    request_item_id = gr.request_item.sys_id+‘‘; 
}

总结:
1 Variables.variable_name不能作为record 查询条件。
2 在确定record的情况下,可以使用gr.variables.variable_name。

Querying Service Catalog Tables

标签:catalog   情况下   walk   val   record   ice   code   查询条件   pre   

原文地址:https://blog.51cto.com/13716461/2485498

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!