FirstRecord Method for a Business Component

The FirstRecord method moves the record pointer to the first record in a business component, making that record the current record. It also calls any associated script events. This method returns the following information:

  • An integer in Siebel VB. It returns 1 or nonzero if it finds at least one record. It returns 0 (zero) if it does not find any records.

  • A Boolean value in Siebel eScript or COM.

If you issue a query on a business component, then Siebel CRM creates SQL for any child business component that is active. Calling the FirstRecord method starts the BusComp_ChangeRecord event and causes Siebel CRM to run the same SQL for the child business component again.

For more information, see NextRecord Method for a Business Component.

Format

BusComp.FirstRecord

No arguments are available.

Used With

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

Examples

To determine if an account displayed in a child applet includes a service request, the following examples use the FirstRecord method. The outcome of this query can determine if Siebel CRM must run other code for this account record. In this example, the Account List Applet is a child applet in the Contact Detail - Accounts View.

The following example is in Siebel eScript:

function BusComp_PreInvokeMethod (MethodName)
{
   // 'CheckSR' method called 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);
         ClearToQuery();
         SetSearchSpec("Account Id", strAccntId);
         ExecuteQuery(ForwardOnly);
         if (FirstRecord())
         {

            // more 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 called 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
         .SetViewMode AllView
         .ClearToQuery
         .SetSearchSpec "Account Id", strAccntId
         .ExecuteQuery ForwardOnly
         If .FirstRecord Then
            '[more code placed here]
         Else
            TheApplication.RaiseErrorText("No Service Requests Associated To This 
Account.")
         End If

      End With

      Set oBC = Nothing
      Set oBO = Nothing

      iRtn = CancelOperation
   End If

   BusComp_PreInvokeMethod = iRtn
End Function