Siebel Object Interfaces Reference > Interfaces Reference > Business Component Methods >
FirstRecord moves the record pointer to the first record in a business component, making that record current and invoking any associated script events.
NOTE: When executing a query on a business component, SQL is generated for any active child business component. Calling the FirstRecord method triggers the BusComp_ChangeRecord event and causes the same SQL for the child business component to execute again.
An integer in Siebel VB: 1 or nonzero if there was a first record (the query returned results) and 0 if there are no records; a Boolean in Siebel eScript, COM, and ActiveX.
COM Data Control, COM Data Server, Java Data Bean, Mobile Web Client Automation Server, Server Script
The following examples show how the FirstRecord method could be used to check whether an Account displayed in a child applet (for example, the Account List Applet - child applet in the Contact Detail - Accounts View) has any service requests associated to it. The outcome of this could then determine whether other code should be run against the Account record.
The following example is in Siebel eScript:
function BusComp_PreInvokeMethod (MethodName)
// 'CheckSR' method invoked from a custom button on 'Account List Applet - child' applet.
if (MethodName == "CheckSR")
var oBO = TheApplication().ActiveBusObject();
var oBC = oBO.GetBusComp("Service Request");
var strAccntId = this.GetFieldValue("Id");
SetSearchSpec("Account Id", strAccntId);
// additional code placed here
TheApplication().RaiseErrorText("No Service Requests Associated To This Account.")
The following example is in Siebel VB:
Function BusComp_PreInvokeMethod (MethodName As String) As Integer
Dim iRtn As Integer
iRtn = ContinueOperation
''CheckSR' method invoked from a custom button On 'Account List Applet - child' Applet.
If MethodName = "CheckSR" Then
Dim oBO As BusObject
Dim oBC As BusComp
Dim strAccntId As String
Set oBO = TheApplication.ActiveBusObject
Set oBC = oBO.GetBusComp("Service Request")
strAccntId = me.GetFieldValue("Id")
.SetSearchSpec "Account Id", strAccntId
If .FirstRecord Then
'[additional code placed here]
TheApplication.RaiseErrorText("No Service Requests Associated To This Account.")
Set oBC = Nothing
Set oBO = Nothing
iRtn = CancelOperation
BusComp_PreInvokeMethod = iRtn