SetSearchExpr Method for a Business Component

The SetSearchExpr method sets a search expression for a business component. This method does not return any information.

Format

BusComp.SetSearchExpr searchSpec

The following table describes the arguments for the SetSearchExpr method.

Argument Description

searchSpec

String that identifies the search specification.

Usage

You can call the SetSearchExpr method after you call the ClearToQuery method and before you call the ExecuteQuery method. It is not necessary to use the ActivateField method on a field that you specify in the SetSearchExpr method.

The maximum length of a predefined query is 2000 characters.

The searchSpec argument works in the same way as the argument you use after the equal sign in a predefined query. For example, consider the following predefined query:

'Account'.Search = "[Name] ~ LIKE ""A. C. Parker"" "

You can use the following equivalent search specification in various interface methods:

BC.SetSearchExpr "[Name] ~ LIKE ""A. C. Parker"" "

In this example, Name is a field in a business component. You must enclose it in square brackets, [ ].

To create a query that includes a sort specification, use the SetSortSpec method. You cannot use the SetSearchExpr method to set a sort specification. Do not use the SetSearchExpr method and the SetSearchSpec method together. These methods are mutually exclusive.

Any date you use with the SetSearchExpr method must use the MM/DD/YYYY format, regardless of the Regional control panel settings on the Siebel Server or the Siebel client.

Using the SetSearchExpr Method with a Keyword

If a field value contains a search keyword, then you must use two pairs of double quotes around the field value. Example keywords include NOT, AND, or OR. For example, if the Sub-Status field includes the string Not an Issue as a field value, then you must use the following Siebel VB format to avoid an SQL error:

substatus = GetFieldValue("Sub-Status") 
searchst = "[Value] = """ & substatus & """"" 
BC.SetSearchExpr searchst

The following Siebel VB format creates an SQL error:

substatus = GetFieldValue("Sub-Status") 
searchst = "[Value] = " & substatus 
BC.SetSearchExpr searchst

Used With

Browser Script, COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following example in Siebel eScript demonstrates how to log the current search specification to a file:

var Ob = TheApplication().ActiveBusObject();
var BC = Ob.GetBusComp("Opportunity");
var Account = "Turston Steel";
var Oppty = "CAD/CAM implementation";
var searchst = "[Name] = '" + Oppty + "' AND [Account] = '" + Account + "'";

TheApplication().TraceOn("c:\\temp\\trace.txt", "Allocation", "All");
TheApplication().Trace("the search expression is: " + searchst);
BC.ClearToQuery();
BC.SetSearchExpr(searchst);
BC.ExecuteQuery(ForwardBackward);

Related Topics

For more information, see the following topics: