Siebel Object Interfaces Reference > Interfaces Reference > Business Component Methods >

SetSearchSpec


SetSearchSpec sets the search specification for a particular field. This method must be called before ExecuteQuery.

Syntax

oBusComp.SetSearchSpec FieldName, searchSpec

Argument
Description
FieldName
String containing the name of the field on which to set the search specification.
searchSpec
String containing the search specification.

Returns

Not applicable

Usage

If ClearToQuery is not called before SetSearchSpec, the business component performs a logical AND on the new search specification and the existing search specification. The maximum length of a predefined query is 2000 characters. Do not use SetSearchExpr and SetSearchSpec together, they are mutually exclusive.

Using logical and comparison operators. Any search specification that can be created in the user interface can be duplicated in Siebel VB or eScript. Both logical operators and comparison operators may be used, provided that they are handled correctly. Here is an example:

BC.SetSearchSpec "Status", "<> 'Closed' AND ([Owner] = LoginName () OR [Refer To] = LoginName ()) OR ([Owner] IS NULL AND [Support Group] = 'TS-AE')"

Using special characters. If the search specification contains any of the following characters:

= > < ( ) , ~ " ' [

it must be enclosed in quotes. This rule applies to operators that are part of the search expression as well as text to search for. If the search expression contains quotes, those quotes must be doubled. For example, in the preceding line of code, notice that the entire search specification is enclosed in double quotes, whereas fields and values referred to within the specification each have single quotes.

If the search object includes a single double quote, that quote must be doubled; for example, if you wanted to search for text containing

"We must

the search specification would take this form:

SetSearchSpec "Comments", "'""We must'"

so that the initial quote is doubled, and the string containing it is placed within single quotes, and the entire expression, including the single quotes, is placed within double quotes.

If the search specification includes single quotes (including apostrophes), the expression must be placed within single quotes, apostrophes must be doubled, and double quotes must be placed around the entire string. Thus, for example, if you wanted to search for "Phillie's Cheese Steaks" in the Name field, you would have to enter the specification as follows:

SetSearchSpec "Name", "'Phillie''s Cheese Steaks'"

NOTE:  eScript and Browser Script require backslashes instead of double quotes for marking special characters. For example: SetSearchSpec("Comments", "\'\"We must\'"); and SetSearchSpec("Name", "\'Phillie\'s Cheese Steaks\'");

Searching for text in non-text fields. If the search expression queries a field of any type other than text, or if it is an expression other than a field-level query, text must be placed within quotes if it contains any characters other than the following:

ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz _ ? \ " ' [

As with text field search expressions, quotes must be doubled.

Retrieving all records. To retrieve all records efficiently, use ClearToQuery followed by ExecuteQuery, without using SetSearchSpec.

Searching for a null field. To search for null fields, use the following form:

SetSearchSpec "Account", "is NULL"

If your search specification requests an empty string, then the search returns every record. For example:

SetSearchSpec "Account", ""

Used With

Server Script, Mobile/Dedicated Web Client Automation Server, COM Data Control, COM Data Server, Java Data Bean, CORBA Object Manager

Example

For Siebel VB examples, read FirstRecord, SetFormattedFieldValue, and BusComp_PreQuery. For a Siebel eScript example, read ClearToQuery.

Example

This code searches for a contact by name and then navigates to the record displayed in a view.

(general) (declarations)
Option Explicit

Sub Button1_Click

   Dim theCurrComp As BusComp
   Dim TargetView As String
   Dim TargetBusObj As String
   Dim TargetBusComp As String
   Dim NewBusObj As BusObject
   Dim NewComp As BusComp

   Dim RecId1 As String
   Dim RecId2 As String
   Dim RecId3 As String

   TargetView = "Visible Contact List View"
   TargetBusObj = "Contact"
   TargetBusComp = "Contact"

   Set theCurrComp = TheApplication.ActiveBusComp
   RecId1 = theCurrComp.GetFieldValue("Last Name")
   RecId2 = theCurrComp.GetFieldValue("First Name")
   RecId3 = theCurrComp.GetFieldValue("Account Id")

   Set NewBusObj = TheApplication.GetBusObject(TargetBusObj)
   Set NewComp = NewBusObj.GetBusComp(TargetBusComp)

   NewComp.ActivateField "Last Name"
   NewComp.ActivateField "First Name"
   NewComp.ActivateField "Account Id"

   NewComp.SetSearchSpec "Last Name", RecId1
   NewComp.SetSearchSpec "First Name", RecId2
   NewComp.SetSearchSpec "Account Id", RecId3

   NewComp.ExecuteQuery ForwardBackward

   TheApplication.GotoView TargetView , NewBusObj

End Sub

Here is an example in Siebel eScript.

var oAccntBO = theApplication().GetBusObject("Account");
var oAccntBC = AccntBO.GetBusComp("Account");
var oAddrBC;

with (oAccntBC)
{
   SetViewMode(SalesRepView);
   ActivateField("Name");
   ClearToQuery();
   SetSearchSpec("Name", "Hong Kong Flower Shop");
   ExecuteQuery()
   oAddrBC = GetMVGBusComp("Street Address")
}

with (oAddrBC)
{
   NewRecord(NewAfter);
   SetFieldValue("City", "Denver");
   WriteRecord();
}

oAddrBC = null;
oAccntBC = null;
oAccntBO = null;

See Also

ExecuteQuery
ClearToQuery
SetSearchExpr
SetSortSpec


 Siebel Object Interfaces Reference 
 Published: 18 June 2003