I am trying to create a business service which will return the count of records according to the status given as Input to it.
'Status' field is a static picklist field. Below is my 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);
}
}
Depending on how your picklist is built, you might need to use this spec instead:
It could also be a visibility problem. The user running the code might not have visibility for those 210 records. You can solve that by using this:
If you want to be sure of what's happening, you can either enable the SQL spool tracing in your dedicated thick client and check the actual query it's executing... or, you can go to any service request applet and query yourself using the syntax
[Status] = 'Active', or[Status] = 'ActiveLovText'(replacingActiveLovTextfor whatever the LookupValue is returning).Also, there are a few things you could improve in your code:
"'"is fine.countvalue in your PropertySet in afinallyblock, which you could reach even before the variable is initialized. Either declare it with an initial value, or place yourSetPropertyline elsewhere.finallyblock to clear used objects, such asbcandbo. You're doind that inside yourtryblock, meaning it won't be done if there is an exception. Not that it would matter in that case, but it's always good practise.Considering all that, this is what the code should look like: