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

FirstRecord Method


FirstRecord moves the record pointer to the first record in a business component, making that record current and invoking any associated script events.

Syntax

BusComp.FirstRecord

Argument
Description

Not applicable

 

Returns

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.

Used With

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

Examples

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");

      with (oBC)
      {
         SetViewMode(AllView);
         ActivateField("Account Id");
         ClearToQuery();
         SetSearchSpec("Account Id", strAccntId);
         ExecuteQuery(ForwardOnly);
         if (FirstRecord())
         {

            // [additional code placed here]
         }

         else
         {
            TheApplication().RaiseErrorText("No Service Requests Associated To This Account.")
         }

      }

      return (CancelOperation);
   }

   return (ContinueOperation);
}

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")

      With oBC
         .ActivateField("Account Id")
         .SetViewMode AllView
         .ClearToQuery
         .SetSearchSpec "Account Id", strAccntId
         .ExecuteQuery ForwardOnly
         If .FirstRecord Then
            '[additional code placed here]
         Else
            TheApplication.RaiseErrorText("No Service Requests Associated To This Account.")
         End If

      End With

      iRtn = CancelOperation
   End If

   BusComp_PreInvokeMethod = iRtn
End Function

See Also

NextRecord Method

Siebel Object Interfaces Reference