ExecuteQuery Method for a Business Component
The ExecuteQuery method uses criteria form another method, such as the SetSearchSpec method, to return a set of business component records. This method allows you to specify the order that Siebel CRM uses to process records.
Format
BusComp.ExecuteQuery ([cursorMode])
The following table describes the arguments for the ExecuteQuery method.
Argument | Description |
---|---|
cursorMode |
An integer. You must use one of the following constants:
For more information, see Use Constants to Standardize Code. |
Usage
To achieve maximum performance, use ForwardOnly. If you use ForwardOnly, make sure that your Siebel application code does not use PreviousRecord or FirstRecord to navigate backward without a requery. Do not use ForwardOnly with a UI business component unless the Siebel application code performs a requery with the cursorMode argument set to ForwardBackward.
A UI business component is a type of business component that Siebel CRM is actively using in the Siebel client. You can write a script that creates a UI business component that does not reference the data the user manipulates. A user might scroll up and down a record set, so you must use ForwardBackward.
You Must Activate Fields Before You Can Query Them
Before you can query a business component, you must use the ActivateField method to activate all fields that are involved in the query. If you write an event handler on a business component, then you must use the ForceActive user property on the control to make sure the field is activate.
Reducing a Large Query Set
If you use ForwardBackward, and if the query matches over 10,000 records, then the object manager returns an error message that is similar to the following:
There were more rows than could be returned. Refine your query to bring back fewer rows.
To reduce the number of queries, you can use a parent-child relationship between business components that the business object establishes. For example, the Opportunity business object establishes a parent-child relationship between the Opportunity business component and the Contact business component. If you instruct Siebel CRM to query the Opportunity business component, then it can read values from the corresponding records in the Contact business component without performing another query. You must instruct Siebel CRM to query the parent business component first, and then to query the child business component. If you query the child business component first, then Siebel CRM returns no records.
How Siebel CRM Handles Duplicate Records with the ExecuteQuery Method
A faulty join configuration or duplicate data in joined tables might cause a business component to return duplicate records. If Siebel CRM detects duplicate records when it executes the ExecuteQuery method, then it does the following work depending on the value of the cursorMode argument:
ForwardBackward. It automatically filters duplicate records to make sure each record is unique.
ForwardOnly. It does not filter records. It returns all records that match the criteria, including duplicate records. If you update all records that Siebel CRM returns, then it displays an error that is similar to the following:
The selected record has been modified by another user since it was retrieved. Please continue.
This error can occur if the code attempts to update the duplicate of a record that it already updated.
Used With
COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script
Examples
This Siebel VB example sets up and runs a query that locates the primary on the account team. Only the primary can modify the primary address.
(general)
(declarations)
Option Explicit
Function BusComp_PreSetFieldValue (FieldName As String,
FieldValue As String) As Integer
Dim i As Integer
Dim iFoundP As Integer ' 1 = found (TRUE), 0 = not found (FALSE)
Dim oMVGBC as BusComp
iFoundP = FALSE
Select Case FieldName
Case "SSA Primary Field"
Set oMVGBC = me.ParentBusComp.GetMVGBusComp("Sales Rep")
With oMVGBC ' this is the position BC
.ActivateField "Active Login Name"
.ActivateField "SSA Primary Field"
.ClearToQuery
.ExecuteQuery ForwardBackward
i = .FirstRecord
Do While i <> 0
If .GetFieldValue("SSA Primary Field") = "Y" Then
iFoundP = TRUE 'mark that found a primary
If .GetFieldValue("Active Login Name") <> TheApplication.LoginName Then
TheApplication.RaiseErrorText"You cannot modify the Primary address
because you are not the Primary on the Account Team")
End If
Exit Do
Loop
If iFoundP = FALSE Then
.FirstRecord
TheApplication.RaiseErrorText("No Primary Found - Contact an Administrator")
End If
End With
End Select
Set oMVGBC = Nothing
BusComp_PreSetFieldValue = ContinueOperation
End Function
For other examples, see the following topics:
Related Topics
For more information, see the following topics: