BusComp_ChangeRecord Event

If a business component record becomes the current record, then Siebel CRM calls the BusComp_ChangeRecord event. This method does not return any information.

Format

BusComp_ChangeRecord

No arguments are available.

Usage

Siebel CRM runs code in the ChangeRecord event handler each time the active record changes. To allow smooth scrolling in a list applet, you must avoid lengthy operations in this event handler.

Used With

Server Script

Examples

The Siebel VB example in this topic uses subprograms in the declarations section of the general section to set up an audit trail for service requests. This example uses the ChangeRecord event handler to initialize the values from the service record so that Siebel CRM can compare them with current values:

(general)
(declarations)
Option Explicit
Dim OldClosedDate, OldCreated, OldOwner, OldOwnerGroup
Dim OldSeverity, OldSource, OldStatus 
Declare Sub CreateAuditRecord
Declare Sub InitializeOldValues

Sub CreateAuditRecord (FieldName As String, NewValue As String, OldValue As String, 
ChangedText As String)

   Dim ActionBC As BusComp
   Dim CurrentBO As BusObject
   Dim theSRNumber

   Set CurrentBO = TheApplication.GetBusObject("Service Request")
   Set ActionBC = CurrentBO.GetBusComp("Action")
   theSRNumber = GetFieldValue("SR Number")

   With ActionBC
      .ActivateField "Activity SR Id"
      .ActivateField "Description"
      .ActivateField "Private"
      .ActivateField "Service request id"
      .ActivateField "Type"
      .NewRecord NewAfter

      .SetFieldValue "Activity SR Id",      theSRNumber
      .SetFieldValue "Description",         ChangedText
      .SetFieldValue "Private",               "Y"
      .SetFieldValue "Type",                "Administration"
      .WriteRecord
   End With
End Sub

Sub InitializeOldValues
   OldClosedDate = GetFieldValue("Closed Date")
   OldOwner = GetFieldValue("Owner")
   OldSeverity = GetFieldValue("Severity")
   If GetFieldValue("Severity") <> OldSeverity Then
      NewValue = GetFieldValue("Severity")
      ChangedText = "Changed Priority from " + OldSeverity + _
         " to " + NewValue
      CreateAuditRecord "Severity", NewValue, OldSeverity, _
         ChangedText
   End If
End Sub

Sub BusComp_ChangeRecord
   InitializeOldValues
End Sub