我正在尝试创建一个业务服务,它将根据作为输入的状态返回记录的计数。
‘'Status’字段是一个静态选择列表字段。下面是我的Siebel eScript。
function getRecordsCount (Inputs, Outputs)
{
var count=0;
try
{
var bo = TheApplication().GetBusObject(Inputs.GetProperty("boname"));
var bc = bo.GetBusComp(Inputs.GetProperty("bcname"));
var LOVText = TheApplication().InvokeMethod("LookupValue",Inputs.GetProperty("lovType"),Inputs.GetProperty("Status"));
with (bc)
{
ClearToQuery();
SetSearchSpec("Status","\'"+LOVText+"\'");
ExecuteQuery(ForwardOnly);
count = CountRecords();
}
bc = null;
bo = null;
}
catch (e)
{
throw (e);
}
finally
{
Outputs.SetProperty("Count",count);
}
}发布于 2016-10-04 11:52:45
根据您的选择列表是如何构建的,您可能需要使用此规范:
bc.SetSearchSpec("Status", "='" + status + "'");这也可能是一个可见性问题。运行代码的用户可能对这210条记录没有可见性。您可以使用以下方法来解决这个问题:
bc.SetViewMode(AllView);如果您想确定发生了什么,您可以在您的专用厚客户端中启用SQL线轴跟踪并检查它正在执行的实际查询.或者,您可以转到任何服务请求applet,并使用语法[Status] = 'Active'或[Status] = 'ActiveLovText'查询自己(无论返回什么LookupValue都替换ActiveLovText )。
此外,您还可以在代码中改进以下几点:
"'"很好。count值存储在PropertySet中的finally块中,甚至在变量初始化之前就可以达到该值。要么用初始值声明它,要么将SetProperty行放在其他地方。finally块来清除已使用的对象,例如bc和bo。您可以在try块中这样做,这意味着如果有异常,就不会执行。在这种情况下,这并不重要,但它总是很好的练习。考虑到所有这些,代码应该是这样的:
function ReturnStatusCount (Inputs, Outputs)
{
var bo:BusObject; // Remove the ":BusObject" and ":BusComp" parts if
var bc:BusComp; // they give you any trouble
try {
var status = Inputs.GetProperty("Status");
var lovText = TheApplication().InvokeMethod("LookupValue", Inputs.GetProperty("lovType"), status);
bo = TheApplication().GetBusObject(Inputs.GetProperty("boname"));
bc = bo.GetBusComp(Inputs.GetProperty("bcname"));
bc.ClearToQuery();
bc.SetViewMode(AllView);
bc.SetSearchSpec("Status", "='" + status + "'"); // status, or lovText maybe
bc.ExecuteQuery(ForwardOnly);
Outputs.SetProperty("Count", bc.CountRecords());
} finally {
bc = null;
bo = null;
}
}https://stackoverflow.com/questions/39793917
复制相似问题