如何在 GlideRecord 上添加字段类型条件?

How to add an field type conditions on GlideRecord?

我需要为 table X 和查询创建一个 GlideRecord,但其中一个参数是条件类型,另一个是 table_name 类型,因为查询是动态的。

如果我尝试,请提醒 "invalid table name: null"。

我的代码:

var tableQueried = new GlideRecord(current.u_ruta);
tableQueried.addQuery(current.u_filtro);
tableQueried.query();

这个问题我可以解决,原来condition type字段被当成一个字符串,所以使用起来很简单,真的没必要post我的问题在这里

您有 2 个选择:-

一个是使用带条件的编码查询而不是 addQuery() 方法:

tableQueried.addEncodedQuery(current.u_filtro);

但是避免错误的首选方法是 GlideFilter.checkRecord()。您可以将其用作:

var tableQueried = new GlideRecord(current.u_rota);
tableQueried.query();
while(tableQueried.next()){
  if(GlideFilter.checkRecord(tableQueried, current.u_filtro)){
     //Do something
  }
}