Siebel Object Interfaces Reference > Siebel Object Interfaces Reference > Object Interfaces Reference >

Business Component Methods


This topic describes business component methods. It includes the following topics:

The oBusComp and BusComp variables that this topic describes refer to an instance of a business component.

ActivateField Method for a Business Component

The ActivateField method activates a field. This method does not return any information. You must use the ActivateField method to activate a field before you can perform a query for the business component. For more information, see DeactivateFields Method for a Business Component.

CAUTION:  Do not use the ActivateField method to activate a field in a UI context business component. This technique might cause unexpected Siebel application behavior. For more information about UI context objects, see Doc ID 477419.1 on My Oracle Support.

Format for the ActivateField Method

BusComp.ActivateField(FieldName)

Table 56 describes the arguments for the ActivateField method.

Table 56. Arguments for the ActivateField Method
Argument
Description

FieldName

String variable or literal that contains the name of the field.

You must enclose the FieldName argument in double quotes. The value you enter for the FieldName argument must match exactly the field name that displays in Siebel Tools, including the same case. For example:

ActivateField("ActivityCreatedByName")

Usage for the ActivateField Method

By default, a field is inactive except in the following situations:

  • The field is a system field, such as Id, Created, Created By, Updated, or Updated By.
  • The Force Active property of the field is TRUE.

    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 active. For more information, see Siebel Developer's Reference.

  • The Link Specification property of the field is TRUE.
  • The field is included in an applet, and this applet references a business component that is active. For a field in a list applet, the Show In List list column property is TRUE.
  • Siebel CRM calls the ActivateField method on the field, and then runs the ExecuteQuery method.

Note the following:

  • If Siebel CRM activates a field after it queries a business component, then it must requery the business component before the user can access the value in that field. If Siebel CRM does not requery the business component, then it returns a value of 0.
  • If Siebel CRM calls the ActivateField method after it calls the ExecuteQuery method, then the ActivateField method deletes the query context.
  • The ActivateField method causes Siebel CRM to include the field in the SQL statement that the ExecuteQuery method starts. If Siebel CRM activates a field, and then if a statement in the GetFieldValue method or the SetFieldValue method references the file before Siebel CRM performs a statement from the ExecuteQuery method, then the activation has no effect. The query contains an empty value because Siebel CRM does not return the activated field through this query.
  • Siebel CRM does not restrict the maximum number of fields that the ActivateField method can activate. This number depends on the SQL query limitations of the database that your deployment uses.
Avoiding a Corrupted Database

If Siebel CRM does not activate a field before it performs a WriteRecord command, then it writes data to the Siebel database, but a corruption problem might occur if a mobile user synchronizes. This situation applies only to mobile users.

To avoid a corrupted database

  1. Use the ActivateField method to call a field.
  2. Call the ExecuteQuery method.
  3. Call the WriteRecord method.

Using this sequence makes sure Siebel CRM writes the field correctly to the transaction log. During synchronization, it saves any modifications that the mobile user makes back to the Siebel database correctly.

Used With

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

Examples

The following example is in Siebel VB. For an equivalent Siebel eScript example, see ClearToQuery Method for a Business Component:

Dim oEmpBusObj As BusObject
Dim oEmpBusComp As BusComp
Dim sLoginName As String

Set oEmpBusObj = TheApplication.ActiveBusObject
Set oEmpBusComp = oEmpBusObj.GetBusComp("Employee")
oEmpBusComp.SetViewMode AllView
oEmpBusComp.ClearToQuery
oEmpBusComp.SetSearchSpec "Login Name", sLoginName
oEmpBusComp.ExecuteQuery ForwardBackward
Set oEmpBusComp = Nothing
Set oEmpBusObj = Nothing

ActivateMultipleFields Method for a Business Component

The ActivateMultipleFields method activates multiple fields. This method returns one of the following values:

  • TRUE if the activation is successful
  • FALSE if the activation is not successful
Format

BusComp.ActivateMultipleFields(SiebelPropertySet)

Table 57 describes the arguments for the ActivateMultipleFields method.

Table 57. Arguments for the ActivateMultipleFields Method
Argument
Description

SiebelPropertySet

Property set that identifies a collection of properties. These properties identify the fields that Siebel CRM must activate.

Used With

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

Examples

The following example is for Siebel Java Data Bean:

import com.siebel.data.*;
...
//Create Siebel Java Data Bean.
//log in to Siebel Java Data Bean
...
//Create Siebel Bus Object.
//Get the Bus Object from SiebelDataBean
...
//Create Siebel Bus Comp siebBusComp
//Get the business component using SiebelBusObject

SiebelPropertySet ps = new mdata_bean.NewPropertySet();
ps.setProperty("Account Products","");
ps.setProperty("Agreement Name","");
ps.setProperty("Project Name","");
ps.setProperty("Description","");
ps.setProperty("Name","");
siebBusComp.ActivateMultipleFields(ps);
...

The following Siebel eScript example queries the Contact business component and returns the First Name and Last Name of the first contact that it finds:

var ContactBO = TheApplication().GetBusObject("Contact");
var ContactBC = ContactBO.GetBusComp("Contact");
with (ContactBC)
{
   SetViewMode(AllView);
   var fieldsPS = TheApplication().NewPropertySet();
   var valuesPS = TheApplication().NewPropertySet();
   fieldsPS. SetProperty("Last Name", "");
   fieldsPS.SetProperty("First Name", "");
   ActivateMultipleFields(fieldsPS);
   ClearToQuery();
   ExecuteQuery(ForwardBackward);
   if (FirstRecord())
   {
      GetMultipleFieldValues(fieldsPS, valuesPS);
      var slName = valuesPS.GetProperty("Last Name");
      var sfName = valuesPS.GetProperty("First Name");
   }
}

Related Topics

For more information, see the following topics:

Associate Method for a Business Component

The Associate method creates a new many-to-many relationship for the parent object through an association business component. This method does not return any information. For more information, see GetAssocBusComp Method for a Business Component.

Format

BusComp.Associate(whereIndicator)

Table 58 describes the arguments for the Associate method.

Table 58. Arguments for the Associate Method
Argument
Description

whereIndicator

You must use one of the following predefined constants:

  • NewBefore
  • NewAfter

For more information, see Use Constants to Standardize Code.

Usage

To set field values on a child record that is associated with a parent record, use the context of the multivalue group business component.

Used With

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

Examples

The following VB example updates the Opportunity Assignment Type field. The parent business component can be any business component that includes the Sales Rep multivalue group:

Dim oParentBC as BusComp
Dim oMvgBC as BusComp
Dim oAssocBC as BusComp

Set oParentBC = me.BusComp
Set oMvgBC = OpBC.GetMVGBusComp("Sales Rep")
Set oAssocBC = oMvgBC.GetAssocBusComp
With oAssocBC
   .SetSearchSpec "Id", newPosId
   .ExecuteQuery
   .Associate NewAfter
End With

oMvgBC.SetFieldValue "Opportunity Assignment Type", "NewType"
oMvgBC.WriteRecord
Set oAssocBC = Nothing
Set oMvgBC = Nothing
Set oParentBC = Nothing

The following Siebel eScript example finds a contact when the Last Name is Abanilla, and then adds a new organization named CKS Software to the Organization multivalue group:

var ok = 0;
var ContactBO= TheApplication().GetBusObject("Contact");
var ContactBC = ContactBO.GetBusComp("Contact");
with (ContactBC)
{
   ClearToQuery();
   SetViewMode(AllView);

   // Searches by Last Name
   SetSearchSpec ("Last Name", "Abanilla");
   ExecuteQuery(ForwardOnly);
   if (FirstRecord())
   {

      // Instantiates Organization MVG
      var oMvgBC = GetMVGBusComp("Organization");
      var oAssocBC = oMvgBC.GetAssocBusComp();
      oAssocBC.ClearToQuery();
      oAssocBC.SetSearchSpec("Name", "CKS Software");
      oAssocBC.ExecuteQuery ();

      // Checks if the Organization was found
      if (oAssocBC.FirstRecord())
      {

         // Organization was found
         try
         {
            oAssocBC.Associate(NewAfter);
            ok = 1;
         }

         catch (e)
         {
            ok = 0;
            TheApplication().RaiseErrorText("Error Associating new Organization");
         }

      } // if oAssocBC.FirstRecord

   } // if FirstRecord

   oAssocBC = null;
   oMvgBC = null;

} // With ContactBC

ContactBC = null;
ContactBO = null;

Related Topics

For more information, see the following topics:

BusObject Method for a Business Component

The BusObject method returns the name of the business object that the business component references. For more information, see ActiveBusObject Method for an Application.

Format

BusComp.BusObject

No arguments are available.

Used With

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

Examples

For an example, see SetViewMode Method for a Business Component.

ClearToQuery Method for a Business Component

The ClearToQuery method clears the current query but does not clear sort specifications on a business component. This method does not return any information. For more information, see RefineQuery Method for a Business Component.

Format

BusComp.ClearToQuery

No arguments are available.

Usage

You must use the ActivateField method to activate a field before you can use the ClearToQuery method. For more information, see ActivateField Method for a Business Component.

Search and sort specifications sent to a business component are cumulative. The business component retains and logically performs an AND operation for the queries that accumulate since the last time Siebel CRM performed the ClearToQuery method. This situation is true except if there is a new search specification on a field, and if that field already included a search specification. In this situation, the new search specification replaces the old search specification.

Used With

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

Examples

The following example is in Siebel eScript.

var oEmpBusObj = TheApplication().ActiveBusObject();
var oEmpBusComp = oEmpBusObj ().GetBusComp("Employee");
var sLoginName;

oEmpBusComp.ClearToQuery();
oEmpBusComp.SetSearchSpec("Login Name", sLoginName);
oEmpBusComp.ExecuteQuery(ForwardBackward);

oEmpBusComp = null;
oEmpBusObj = null;

For more examples, see the following:

CountRecords Method for a Business Component

The CountRecords method returns the number of records that the most recent call to the ExecuteQuery method returned.

Format

BusComp.CountRecords()

No arguments are available.

Used With

Server Script

Examples

The following example is in Siebel eScript:

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
   if (MethodName == "Call_eScript")
   {
      var bo = TheApplication().GetBusObject("Opportunity");
      var bc = bo.GetBusComp("Opportunity");
      with (bc)
      {
         ClearToQuery();
         SetSearchSpec ("Name", "A*");
         ExecuteQuery(ForwardBackward);
         var count = CountRecords();
      }

      // other code..

      bc = null;
      bo = null;

      return (CancelOperation);
   }

   return (ContinueOperation);
}

DeactivateFields Method for a Business Component

The DeactivateFields method deactivates fields from the SQL query statement of a business component. It deactivates fields that are currently active. This situation is true except in the following situations:

  • The Force Active property is TRUE
  • A link requires the field to remain active.
  • A business component class requires the field to remain active.

This method does not return any information.

Format

BusComp.DeactivateFields

No arguments are available.

Usage

You must use the ActivateField method to activate a field before you perform a query for a business component. For more information, see ActivateField Method for a Business Component.

After you deactivate a field, you must query the business component again or the Siebel application fails.

Used With

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

Examples

The following example is for the Component Object Model (COM):

Dim oBO As BusObject
Dim OBC As BusComp
Dim errCode

Set oBO = SiebelApplication.GetBusObject("Account", errCode)
Set oBC = oBO.GetBusComp("Account", errCode)
oBC.ActivateField "Name", errCode
oBC.ActivateField "Location", errCode
oBC.ClearToQuery errCode
oBC.ExecuteQuery ForwardOnly, errCode

' Manipulate the data

oBC.DeactivateFields errCode
Set oBC = Nothing
Set oBO = Nothing

The following example is in Siebel eScript:

var oBC;
var oBO;

oBO = TheApplication().GetBusObject("Account");
oBC = oBO.GetBusComp("Account");
oBC.ActivateField("Name");
oBC.ActivateField("Location");
oBC.ClearToQuery();
oBC.ExecuteQuery(ForwardOnly);

// Manipulate the data

oBC.DeactivateFields();
oBC = null;
oBO = null;

The following example is in Siebel VB:

Dim oBO As BusObject
Dim oBC As BusComp

Set oBO = TheApplication.GetBusObject("Account")
Set oBC = oBO.GetBusComp("Account")
oBC.ActivateField "Name"
oBC.ActivateField "Location"
oBC.ClearToQuery
oBC.ExecuteQuery ForwardOnly

' Manipulate the data

oBC.DeactivateFields
Set oBC = Nothing
Set oBO = Nothing

DeleteRecord Method for a Business Component

The DeleteRecord method removes the current record from a business component. This method does not return any information.

Format

BusComp.DeleteRecord

No arguments are available.

Used With

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

Examples

This Siebel VB example deletes accounts with a status of Inactive:

Sub DeleteInactiveAccounts()
   Dim objBO as BusObject
   Dim objBC as BusComp

   Set objBO = TheApplication.GetBusObject("Account")
   Set objBC = objBO.GetBusComp("Account")
   With objBC
      .ClearToQuery
      .SetSearchSpec "Status", "Inactive"
      .ExecuteQuery ForwardBackward
      Do While .FirstRecord
         .DeleteRecord
      Loop
   End With
   Set objBC = Nothing
   Set objBO = Nothing
End Sub

Siebel CRM moves the cursor to the next record after it runs the DeleteRecord method. Do not use the NextRecord method after you use the DeleteRecord method in a loop because this configuration causes Siebel CRM to skip deleting the last record in the loop. If you use the DeleteRecord method on the last record, then the cursor points to nothing.

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

Table 59 describes the arguments for the ExecuteQuery method.

Table 59. Arguments for the ExecuteQuery Method
Argument
Description

cursorMode

An integer. You must use one of the following constants:

  • ForwardBackward. Siebel CRM processes records from first to last or from last to first. If you do not provide a value for the cursorMode argument, then Siebel CRM uses ForwardBackward.
  • ForwardOnly. Siebel CRM processes records only from the first record to the last record. Siebel CRM does return to a prior record.

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:

ExecuteQuery2 Method for a Business Component

The ExecuteQuery2 method uses criteria form another method, such as SetSearchSpec, to return a set of business component records. Allows you to control the number of records Siebel CRM returns.

Format

BusComp.ExecuteQuery2 ([cursorMode], ignoreMaxCursorSize)

Table 60 describes the ignoreMaxCursorSize argument for the ExecuteQuery2 method. For the cursorMode argument, see Table 59.

Table 60. Arguments for the ExecuteQuery2 Method
Argument
Description

ignoreMaxCursorSize

You can use one of the following values:

  • TRUE. Returns every record from a business component. This value might result in lower performance.
  • FALSE. Returns the number of records according to the value in the MaxCursorSize argument. You can define the MaxCursorSize argument in the Siebel application configuration (CFG) file.
Used With

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

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, COM, or ActiveX.

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

FirstSelected Method for a Business Component

The FirstSelected method makes the first record of the multiple selection in a business component active. It also calls any associated events. It returns the same information as the FirstRecord method. For more information, see FirstRecord Method for a Business Component.

Format

BusComp.FirstSelected

No arguments are available.

Used With

COM Data Server, Server Script

Examples

The following examples use the FirstSelected method and the NextSelected method to allow you to customize multirecord deletion. If the user clicks a custom button in an applet, then Siebel CRM can call this code and it can call the Delete Selected custom method.

The following example is in Siebel eScript:

function BusComp_PreInvokeMethod (MethodName)
{
   if (MethodName == "Delete Selected")
   {
      with (this)
      {
         var iRecord = FirstSelected();

         while (iRecord)
         {
            DeleteRecord();
            iRecord = NextSelected();
         }

      }

      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
   If MethodName = "Delete Selected" Then

      With me
         Dim iRecord As Integer

         iRecord = .FirstSelected

         While iRecord
            .DeleteRecord
            iRecord = .NextSelected
         Wend

      End With

      iRtn = CancelOperation

   End If

   BusComp_PreInvokeMethod = iRtn
End Function

GetAssocBusComp Method for a Business Component

The GetAssocBusComp method returns a string that contains the name of the association business component. You can use the association business component to manipulate the association.

Format

BusComp.GetAssocBusComp

No arguments are available.

Usage for the GetAssocBusComp Method

It is appropriate to use the GetAssocBusComp method and the Associate method only with a many-to-many relationship that uses an intersection table. For example, account and industry. In the context of a many-to-many relationship, you can use Siebel VB to do the following:

  • To associate a new record, add it to the child business component. To add a record, you use the GetAssocBusComp method and the Associate method. You set the GetAssocBusComp method to Nothing in Siebel VB or null in Siebel eScript.
  • To insert a record, create a new record in the child business component. To insert a record, you use the GetMVGBusComp method and the NewRecord method.

If a many-to-many link exists, and if an association applet is defined for the child applet, then you can use the GetAssocBusComp method with the child business component of a parent-child view. You can use this technique instead of modifying the multivalue group business component.

Used With

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

Examples

The following example is in Siebel VB. It uses the GetAssocBusComp method to add a new industry to an account:

Dim oAssocBC As BusComp

Set oAssocBC = oMainBc.GetMVGBusComp("Industry").GetAssocBusComp
With oAssocBC
   .ClearToQuery
   .SetSearchExpr "[SIC Code] = ""5734"""
   .ExecuteQuery ForwardOnly

   If .FirstRecord Then .Associate NewBefore
End With
Set oAssocBC = Nothing

The following is the same example in Siebel eScript:

//get the business Object and the business component
var oAssocBC = oMainBc.GetMVGBusComp("Industry").GetAssocBusComp();
with (oAssocBC)
{
   ClearToQuery;
   SetSearchExpr("[SIC Code] = '5734'");
   ExecuteQuery(ForwardOnly)
   if (FirstRecord())
      Associate(NewBefore);
}
oAssocBC = null;

Related Topics

For more information, see the following topics:

GetFieldValue Method for a Business Component

The GetFieldValue method returns one of the following items:

  • A string that contains the value of a field from the current record of a business component.
  • An empty string if the field is empty.
  • An error message if the field is inactive. To avoid this situation, activate the field before you use the GetFieldValue method. For more information, see ActivateField Method for a Business Component.

The GetFieldValue method uses the MM/DD/YYYY format when it returns a date field regardless of what format the local date uses. To return the date in the same format that the local date uses, you can use the GetFormattedFieldValue method. For more information, see GetFormattedFieldValue Method for a Business Component.

In Browser Script, you can use the GetFieldValue method only if the field is available in the applet and for system fields.

Format

BusComp.GetFieldValue(FieldName)

The arguments you can use in this format are the same as the arguments that are described in Table 56.

Usage for the GetFieldValue Method

If you require a value from a business component that is a parent of the current business component, then you must make sure the Link Specification property for that field is set to TRUE in Siebel Tools. If it is not, then the child business component cannot access the value in the parent business component. For more information, see Siebel Object Types Reference.

Used With

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

Examples

The following example is in Siebel VB:

Function BusComp_PreSetFieldValue (FieldName As String, FieldValue As String) As Integer

   Dim bcOppty As BusComp
   Dim boBusObj As BusObject
   Dim srowid As String

   srowid = GetFieldValue("Id")
   Set boBusObj = TheApplication.GetBusObject("Opportunity")
   Set bcOppty = boBusObj.GetBusComp("Opportunity")
   With bcOppty
      .SetViewMode SalesRepView
      .ActivateField "Sales Stage"
      .SetSearchSpec "Id", srowid
      .ExecuteQuery ForwardOnly
   End With

   Set bcOppty = Nothing
   Set boBusObj = Nothing

End Function

The following example is in Siebel eScript:

function BusComp_PreSetFieldValue (FieldName, FieldValue)

   var boBusObj = TheApplication().GetBusObject("Opportunity");
   var bcOppty = boBusObj.GetBusComp("Opportunity");
   var srowid = GetFieldValue("Id");

   with (bcOppty)
   {
      SetViewMode(SalesRepView);
      ActivateField("Sales Stage");
      SetSearchSpec("Id", srowid);
      ExecuteQuery(ForwardOnly);
   }

   bcOppty = null;
   boBusObj = null;
}

GetFormattedFieldValue Method for a Business Component

The GetFormattedFieldValue method returns the following information:

  • A string that contains a field value that is in the same format that the Siebel client uses.
  • An empty string if the field is inactive or empty.
Format

BusComp.GetFormattedFieldValue(FieldName)

The arguments you can use in this format are the same as the arguments that are described in Table 56.

Usage

You can use the GetFormattedFieldValue method with code that your implementation uses in multiple countries that use different formats for currency, date, or numbers.

Usage with Phone Data and Date Data

The following behavior exists for phone data and date data:

  • DTYPE_PHONE. If you use the GetFormattedFieldValue method with a field whose Type property is DTYPE_PHONE, then this method returns a formatted phone number.

    Example 1:

    phone = bc.GetFieldValue("Main Phone Number")
    TheApplication.Trace "The number is " & phone

    Result:

    The number is 8869629123

    Example 2:

    phone = bc.GetFormattedFieldValue("Main Phone Number")
    TheApplication.Trace "The number is " & phone

    Result:

    The number is (886) 962-9123

  • DTYPE_DATE. If you use the GetFormattedFieldValue method with a field whose Type property is DTYPE_DATE, then the result is the same as the GetFieldValue method or the SetFieldValue method except that the GetFormattedFieldValue method returns the value in the same format as the Regional Setting.

Table 61 describes the formats that the GetFieldValue method and the SetFieldValue method use.

Table 61. Date and Time Formats That the GetFieldValue Method and SetFieldValue Method Use
Type of Data
Format

Dates

mm/dd/yyyy

Times

hh:nn:ss

Date-times

mm/dd/yyyy hh:nn:ss

If you attempt to use the SetFieldValue method, and if the Regional Setting format is different, the Siebel CRM displays an error that is similar to the following:

Error: The value '31-Dec-99' can not be converted to a date time value.

To avoid this error, use the GetFormattedFieldValue format or the SetFormattedFieldValue method.

Used With

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

Examples

The following Siebel VB example uses the GetFormattedFieldValue method and calculates the number of days between two dates:

Sub Button_Click
   Dim DateDiff as Integer
   Dim oBC as BusComp
   Set oBC= me.BusComp
   x = oBC.GetFormattedFieldValue("Start Date")
   y = oBC.GetFormattedFieldValue("Done")
   dx = DateValue(x)
   dy = DateValue(y)
   DateDiff = dy - dx
End Sub

Related Topics

For more information, see the following topics:

GetLastErrCode Method for a Business Component

The GetLastErrCode method returns the error code for the error that Siebel CRM logged most recently. This code is a short integer. 0 (zero) indicates no error.

Format

BusComp.GetLastErrCode

No arguments are available.

Usage

For more information, see Usage for the GetLastErrCode Method.

Used With

COM Data Control, Mobile Web Client Automation Server

GetLastErrText Method for a Business Component

The GetLastErrText method returns a string that contains the text message for the error that Siebel CRM logged most recently.

Format

BusComp.GetLastErrText

No arguments are available.

Usage

For more information, see Usage for the GetLastErrText Method.

Used With

COM Data Control, Mobile Web Client Automation Server

GetMultipleFieldValues Method for a Business Component

The GetMultipleFieldValues method returns a value for each field specified in a property set. It also returns the following information:

  • TRUE if it finds the fields.
  • FALSE if it does not find the fields.

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

Format

BusComp.GetMultipleFieldValues(fieldNamesPropSet, fieldValuesPropSet)

Table 62 describes the arguments for the GetMultipleFieldValues method.

Table 62. Arguments for the GetMultipleFieldValues Method
Argument
Description

fieldNamesPropSet

A property set that identifies a collection of fields.

fieldValuesPropSet

A property set that provides values for the fields specified in the fieldNamesPropSet argument.

Usage

You cannot use the same instance of a property set for the fieldNamesPropSet argument and for the fieldValuesPropSet argument.

Used With

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

Examples

The following example is in Siebel eScript:

  try {

var oPsDR_Header:PropertySet = TheApplication().NewPropertySet();

// Cannot use the same property set in GetMultipleFieldValues, must use a different // one for the values. The process will not error, but the values will not be placed // in the property set.

var lPS_values:PropertySet = TheApplication().NewPropertySet();

oPsDR_Header.SetProperty("Last Name","");

oPsDR_Header.SetProperty("First Name","");

oPsDR_Header.SetProperty("Middle Name","");

var boContact = TheApplication().GetBusObject("Contact");

var bcContact = boContact.GetBusComp("Contact");

with (bcContact) {

ClearToQuery();

SetViewMode(AllView);

ActivateMultipleFields(oPsDR_Header);

SetSearchSpec("Last Name", "Mead*");

ExecuteQuery(ForwardOnly);

var isParent = FirstRecord();

do {

  // Use a different property set for the values. If you use the same one

  // for arguments you get no values back.

  GetMultipleFieldValues(oPsDR_Header, lPS_values);

  // Get the value from the output property set.

  TheApplication().Trace("Last Name = " +
  lPS_values.GetProperty("Last Name"));

  } while (NextRecord());

} //end with

} //end try

  catch(e) {

TheApplication().Trace(e.toString());

}//end catch

GetMVGBusComp Method for a Business Component

The GetMVGBusComp method returns the multivalue group business component that is associated with a business component field.

Format

BusComp.GetMVGBusComp(FieldName)

The arguments you can use in this format are the same as the arguments that are described in Table 56 except the GetMVGBusComp method uses the FieldName argument to identify the multivalue group business component.

Usage

A multivalue group is a set of detail records attached to the current record in a business component that holds the corresponding multivalue field. After you run the GetMVGBusComp method, it is recommended that you set the multivalue group business component to one of the following:

  • Nothing in Siebel VB
  • Null in Siebel eScript
Used With

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

Examples

The following example Siebel VB code uses the GetMVGBusComp method to add a new address to the Hong Kong Flower Shop account:

Dim AccntBO as BusObject
Dim AccntBC as BusComp
Dim AddrBC as BusComp
Set AccntBO = TheApplication.GetBusObject "Account"
Set AccntBC = AccntBO.GetBusComp "Account"

With AccntBC
   .SetViewMode SalesRepView
   .ClearToQuery
   .SetSearchSpec "Name", "Hong Kong Flower Shop"
   .ExecuteQuery
   If (.FirstRecord) Then Set AddrBC = .GetMVGBusComp ("Street Address")

With AddrBC
   .NewRecord NewAfter
   .SetFieldValue "City", "Denver"
   .SetFieldValue "Street Address", "123 Main Street"
   .WriteRecord
End With

   End If

End With

Set AddrBC = Nothing
Set AccntBC = Nothing
Set AccntBO = Nothing

For more examples, see the following topics:

For more information about inserting records, see Usage for the GetAssocBusComp Method:

GetNamedSearch Method for a Business Component

The GetNamedSearch method returns a string that contains the name of a search specification.

Format

BusComp.GetNamedSearch(searchName)

Table 63 describes the arguments for the GetNamedSearch method.

Table 63. Arguments for the GetNamedSearch Method
Argument
Description

searchName

Name of the search specification that references the search string.

Usage

The search specification uses the same format that a predefined query uses.

Used With

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

Related Topics

For more information, see the following topics:

GetPicklistBusComp Method for a Business Component

The GetPicklistBusComp method returns the name of the pick business component that is associated with a field in the current business component. If there is no picklist associated with this field, then this method returns an error.

Format

BusComp.GetPicklistBusComp(FieldName)

The arguments you can use in this format are the same as the arguments that are described in Table 56, except the GetPicklistBusComp method uses the FieldName argument to identify the pick business component.

Usage

To manipulate a picklist, you can use the name of the pick business component that the GetPicklistBusComp method returns.

After you run the GetPickListBusComp method, it is recommended that you set the pick business component to one of the following:

  • Nothing in Siebel VB
  • Null in Siebel eScript
Picking a Record on a Constrained Picklist

If Siebel CRM uses the GetPickListBusComp method or the Pick method to pick a record on a constrained picklist, then the constraint is active. The pick business component that these methods return contains only those records that fulfill the constraint.

To Pick a Value From a Picklist in Siebel VB

You can pick a value from a picklist in Siebel VB.

To pick a value from a picklist in Siebel VB

  1. Use the GetPicklistBusComp method to create an instance of the picklist business component.
  2. Navigate in the pick business component to the record you must pick.
  3. Use Pick to pick the value.
  4. To explicitly delete this instance of the pick business component, use the following code:

    Set objBCPickList = Nothing.

Used With

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

Examples

The following example is in Siebel eScript:

if (this.GetFieldValue("City") == "San Mateo")
{
   var oBCPick = this.GetPicklistBusComp("State");
   with (oBCPick)
   {
      ClearToQuery();
      SetSearchSpec("Value", "CA");
      ExecuteQuery(ForwardOnly);
      if (FirstRecord())
         Pick();
   }
   oBCPick = null;
}

The following example is for Siebel Java Data Bean. It chooses a product from a picklist:

Sieb_busObject = Sieb_dataBean.getBusObject("Service Request");
Sieb_busComp = Sieb_busObject.getBusComp("Service Request");
Sieb_busComp.newRecord(false);

. . .

SiebelBusComp productBusComp = Sieb_busComp.getPicklistBusComp("Product");
productBusComp.clearToQuery();
productBusComp.setSearchSpec("Name", "ATM Card");
productBusComp.executeQuery(false);
isRecord =productBusComp.firstRecord();
try
{
   if (isRecord)
   productBusComp.pick();
   Sieb_busComp.writeRecord();
}

catch (SiebelException e)
{
   System.out.println("Error in Pick " + e.getErrorMessage());
}

The following example is in Siebel VB:

If Me.GetFieldValue("City") = "San Mateo" Then
   Set oBCPick = Me.GetPicklistBusComp("State")
   With oBCPick
      .ClearToQuery
      .SetSearchSpec "Value", "CA"
      .ExecuteQuery ForwardOnly
      If .FirstRecord Then .Pick
   End With
   Set oBCPick = Nothing
End If

Related Topics

For more information, see the following topics:

GetSearchExpr Method for a Business Component

The GetSearchExpr method returns a string that contains the current search expression that is defined for a business component. For example:

[Revenue] > 10000 AND [Probability] > .5

If an instance of the business component does not exist, then the GetSearchExpr method returns nothing. If you use the GetSearchExpr method in Browser Script with the Applet_PreInvokeMethod event, then it returns a null value even if you add a query filter.

Format

BusComp.GetSearchExpr

No arguments are available.

Used With

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

Related Topics

For more information, see the following topics:

GetSearchSpec Method for a Business Component

The GetSearchSpec method returns a string that contains the search specification that is defined for a business component. For example, > 10000.

Format

BusComp.GetSearchSpec(FieldName)

The arguments you can use in this format are the same as the arguments that are described in Table 56, except the GetSearchSpec method uses the FieldName argument to identify the search specification.

Used With

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

Related Topics

For more information, see the following topics:

GetSortSpec Method for a Business Component

The GetSortSpec method returns the sort specification for a business component.

Format

this.GetSortSpec();

No arguments are available.

Used With

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

Related Topics

For more information, see the following topics:

GetUserProperty Method for a Business Component

The GetUserProperty method returns the value of a user property.

Format

BusComp.GetUserProperty(propertyName)

Table 64 describes the arguments for the GetUserProperty method.

Table 64. Arguments for the GetUserProperty Method
Argument
Description

propertyName

The name of the user property.

Usage for the GetUserProperty Method

A user property is similar to an instance variable of a business component. You can use the GetUserProperty method to access a user property from anywhere in the code, even from another application through COM.

An instance variable is a type of variable that is defined at the top level of the business component in the general declarations section. You can access an instance variable only in Siebel VB, and in the same object where you declare the instance variable. For more information, see SetUserProperty Method for a Business Component.

Siebel CRM resets the value of a user property every time you create a business component instance.

The GetUserProperty method does not interact directly with user properties that you define in Siebel Tools.

Used With

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

GetViewMode Method for a Business Component

The GetViewMode returns a Siebel ViewMode constant or the corresponding integer value for this constant. This constant identifies the current visibility mode for a business component. This mode effects the records that queries return according to the visibility rules. For more information, see SetViewMode Method for a Business Component and Use Constants to Standardize Code.

Format

BusComp.GetViewMode

No arguments are available.

Usage

The GetViewMode method returns NoneSetView mode until one of the following situations is true:

  • Siebel CRM queries a business component.
  • The SetViewMode method sets the view mode for the business component.

The NoneSetViewMode value indicates that no visibility rules are applied to the business component. If Siebel CRM creates a business component through a call to the GetBusComp method, then the value for that business component is NoneSetViewMode. If you require a specific view mode, then you must use the SetViewMode method to set this view mode. If you do not use the SetViewMode method, then Siebel CRM sets the view mode according to the most restrictive visibility mode that is defined for that business component. It does this the first time that it creates a business component instance.

Used With

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

InvokeMethod Method for a Business Component

The InvokeMethod method calls a method. It returns a string that contains the result of the method. For more information, see About Specialized and Custom Methods.

Siebel VB Format

BusComp.InvokeMethod methodName, methArg1, methArg2, methArgN

Table 65 describes the arguments for the Siebel VB format of the InvokeMethod method.

Table 65. Arguments for the Siebel VB Format of the InvokeMethod Method
Argument
Description

methodName

The name of the method. For information about the values you can enter for this argument, see Business Component Invoke Methods.

You can use the following arguments:

  • methArg1
  • methArg2
  • methArgN

A single string that contains arguments for the methodName argument.

You can also pass this string in an array that contains the method parameters.

Siebel eScript Format

BusComp.InvokeMethod(methodName, methArg1, methArg2, ..., methArgn);

The arguments you can use in this format are the same as the arguments that are described in Table 23.

Usage

You can use the InvokeMethod method to call a method on a business component object that is not available directly through the object interface. For more information, see Caution About Using the InvokeMethod Method.

Used With

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

Examples

For examples of using the InvokeMethod method, see the following topics:

LastRecord Method for a Business Component

The LastRecord method moves the record pointer to the last record in a business component. It returns one of the following items:

  • An integer in Siebel VB
  • A Boolean value in ActiveX, COM, Siebel Java Data Bean, or Siebel eScript

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

Format

BusComp.LastRecord

No arguments are available.

Used With

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

Examples

The following example is for the Mobile Web Client Automation Server:

Private Sub LastRecord_Click()

   Dim errCode As Integer
   Dim oBusComp as SiebelBusComp
   FieldValue.Text = ""
   oBusComp.ClearToQuery
   oBusComp.ExecuteQuery ForwardBackward
   oBusComp.LastRecord errCode
   If errCode = 0 Then
      FieldValue.Text = oBusComp.GetFieldValue(FieldName.Text, _
         errCode)
   End If

   Status.Text = SiebelApplication.GetLastErrText
End Sub

Name Method for a Business Component

The Name method returns a string that contains the name of a business component.

Format

BusComp.Name()

No arguments are available.

Used With

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

Examples

The following example is in Browser Script:

function BusComp_PreSetFieldValue (fieldName, value)
{
   theApplication().SWEAlert(this.Name());
}

NewRecord Method for a Business Component

The NewRecord method adds a new record to a business component. This method does not return any information.

Format

BusComp.NewRecord(whereIndicator)

Table 66 describes the arguments for the NewRecord method.

Table 66. Arguments for the NewRecord Method
Argument
Description

whereIndicator

Predefined constant that configures where Siebel CRM must add the new record. You can use one of the following values:

  • NewBefore
  • NewAfter
  • NewBeforeCopy
  • NewAfterCopy

For more information, see Use Constants to Standardize Code.

If you use Siebel Java Data Bean, then you can use one of the following values:

  • FALSE. This value is equivalent to the NewBefore constant.
  • TRUE. This value is equivalent to the NewAfter constant.
Usage

If you use the NewRecord method to add a new record, then Siebel CRM does the following:

  1. Places the new record before or after the current record, depending on the value you enter for the WhereIndicator argument.
  2. Sets this new record as the current record.

You can use the NewRecord method to copy a record. To place the copy before the original record, you use the following command:

Object.NewRecord NewBeforeCopy

To place the copy after the original record, you use the following command:

Object.NewRecord NewAfterCopy

Performance with the NewRecord Method

In some situations, using the NewRecord method in a Server Script can result in this method performing slowly. In this situation, Siebel CRM does not display an error message. It creates the record but the reply time is not optimal. This situation is due to the expected behavior of the Siebel application when it creates a new record.

To position the new record in the record set, Siebel CRM gets the cursor for the record set. This record set must include data before Siebel CRM creates the new record. In the context of a script, Siebel CRM must run a query on the business component before it calls the NewRecord method. If the script does not explicitly run the query, then Siebel CRM runs a full table query. This situation can cause suboptimal performance. For more information, see Doc ID 477556.1 on My Oracle Support.

Used With

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

Examples

The following example is in Siebel VB:

Dim oBusObj as BusObject
Dim oBC as BusComp

Set oBusObj = TheApplication.ActiveBusObject
Set oBC = oBusObj.GetBusComp("Action")
oBC.NewRecord NewAfter
oBC.SetFieldValue "Type", "To Do"
oBC.SetFieldValue "Description", "Find Decision Makers"
oBC.WriteRecord

set oBC = Nothing
set oBusObj = Nothing

NextRecord Method for a Business Component

The NextRecord method moves the record pointer to the next record in a business component, making that record the current record. This method returns the following information:

  • In Siebel VB, an integer that includes one of the following values:
    • 1. Indicates the method successfully moved the record pointer to the next record.
    • 0 (zero). Indicates the method did not move the record pointer because it points to the last record.
  • In Siebel eScript and COM, a Boolean value.
Format

BusComp.NextRecord

No arguments are available.

Used With

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

Examples

The following example is in Siebel eScript:

var isRecord;

with (this)
{

ClearToQuery();
SetSearchSpec("Name", "A*");
ExecuteQuery(ForwardBackward);
isRecord = FirstRecord();
while (isRecord)
{

// do some record manipulation
isRecord = NextRecord();

}

}

For a similar Siebel VB example, see FirstRecord Method for a Business Component.

NextSelected Method for a Business Component

The NextSelected method makes the next record of the current multiple selection the active record. It returns the same information as the NextRecord method. For more information, see NextRecord Method for a Business Component.

Format

BusComp.NextSelected

No arguments are available.

Used With

Server Script

Examples

For examples, see FirstSelected Method for a Business Component.

ParentBusComp Method for a Business Component

The ParentBusComp method returns the name of the parent business component of a link.

Format

BusComp.ParentBusComp

No arguments are available.

Usage

The ParentBusComp method allows you to write code in the child business component that can access a field value or perform actions in the parent business component. To use this method, it might be necessary to set the Link Specification property. For more information, see Usage for the GetFieldValue Method.

Used With

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

Examples

The following example is in Siebel VB. For another example, see ExecuteQuery Method for a Business Component:

Dim strParentName as String
...
strParentName = Me.ParentBusComp.GetFieldValue("Name")

Pick Method for a Business Component

The Pick method places the currently chosen record in a pick business component into the appropriate fields of the parent business component. This method does not return any information.

You cannot use the Pick method to modify the record in a read-only picklist field.

Format

BusComp.Pick

No arguments are available.

Usage

For more information, see Picking a Record on a Constrained Picklist.

Used With

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

Examples

The following Siebel VB example sorts the values in the Sales Stage field:

Sub BusComp_NewRecord
   Dim oBC as BusComp
   set oBC = me.GetPickListBusComp("Sales Stage")

   With oBC
      .ClearToQuery
      .SetSearchSpec "Sales Stage", "2 - Qualified"
      .ExecuteQuery ForwardOnly
      if .FirstRecord then .Pick
   End With

   set oBC = Nothing
End Sub

The following is the equivalent example in Siebel eScript:

function BusComp_NewRecord ()
{
   var oBC = this.GetPickListBusComp("Sales Stage");
   with (oBC)
   {
      ClearToQuery();
      SetSearchSpec("Sales Stage", "2 - Qualified");
      ExecuteQuery(ForwardOnly);
      if (FirstRecord())
         Pick();
   }
   oBC = null;
}

PreviousRecord Method for a Business Component

The PreviousRecord method moves the record pointer to the previous record in a business component, making that record the current record. This method returns one of the following values:

  • An integer in Siebel VB that includes one of the following values:
    • 1. Indicates the method successfully moved the record pointer to the next record.
    • 0 (zero). Indicates the method did not move the record pointer because it points to the last record.
  • A Boolean value in Siebel eScript and COM.
Format

BusComp.PreviousRecord

No arguments are available.

Usage

You can use the PreviousRecord method only on a business component that Siebel CRM has queried with the CursorMode mode argument set to ForwardBackward. For more information, see ExecuteQuery Method for a Business Component.

Used With

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

Examples

The following Siebel eScript example locates the next-to-last record in a query and then manipulates it:

with (this)

{

ActivateField("Name")

ClearToQuery();

SetSearchSpec("Name", "A*");

ExecuteQuery(ForwardBackward);

isRecord = FirstRecord();

while (isRecord)

{

// do some record manipulation

isRecord = NextRecord();

} // end while loop

nextToLastRecord = PreviousRecord();

if (nextToLastRecord) // verify that there is a penultimate record

{

// do some more record manipulation that applies only to next-to-last record

} // end if

} // end with

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

RefineQuery Method for a Business Component

The RefineQuery method refines a query. This method does not return any information.

Format

BusComp.RefineQuery

No arguments are available.

Usage

Unlike the ClearToQuery method, the RefineQuery method retains the existing query specification and allows you to add search conditions that include those fields that Siebel CRM has not set through a previous search expression. The RefineQuery method is most useful if you use it with the GetNamedSearch method. For more information, see ClearToQuery Method for a Business Component and GetNamedSearch Method for a Business Component.

Used With

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

Examples

The following Siebel VB code uses RefineQuery:

me.SetSearchSpec "Status", "Open"
me.ClearToQuery
me.ExecuteQuery
me.RefineQuery
me.SetSearchSpec "Substatus", "Assigned"
me.ExecuteQuery

Release Method for a Business Component

The Release method releases a business component and the resources for this business component that exist on the Siebel Server. This method does not return any information.

Format

BusComp.release()

No arguments are available.

Used With

Siebel Java Data Bean

Examples

The following example is for Siebel Java Data Bean:

import com.siebel.data.*;
{
   ...   
// create Siebel Java Data Bean
   // log in to Siebel Java Data Bean   
...
   // Create Siebel Bus Object.
// get the Bus Object from SiebelDataBean
   ...
   // Create Siebel Bus Comp siebBusComp   
// Get the business component using SiebelBusObject
   ...   
// Use the bus. Component   
...   
// make sure to release the business component and its resources on the Siebel Server    siebBusComp.release();   
// release the resources occupied by Siebel Bus Object and Siebel Java Data Bean after their use.
}

The following example logs in to a Siebel Server. It then creates an instance for each of the following items:

  • Business object
  • Business component
  • Business service

It then releases each of these items in reverse order:

import com.siebel.data.*;
import com.siebel.data.SiebelException;

public class JDBReleaseDemo
{
   private SiebelDataBean m_dataBean = null;
   private SiebelBusObject m_busObject = null;
   private SiebelBusComp m_busComp = null;
   private SiebelService m_busServ = null;

   public static void main(String[] args)
   {
      JDBReleaseDemo demo = new JDBReleaseDemo();
   }

   public JDBReleaseDemo()
   {
      try
      {

         // instantiate the Siebel Java Data Bean
         m_dataBean = new SiebelDataBean();

         // login to the Siebel Servers
         m_dataBean.login("siebel.tcpip.none.none://gateway:port/enterprise/
         object manager","userid","password");
         System.out.println("Logged in to the Siebel Server ");

         // get the business object
         m_busObject = m_dataBean.getBusObject("Account");

         // get the business component
         m_busComp = m_busObject.getBusComp("Account");

         // get the business service
         m_busServ = m_dataBean.getService("Workflow Process Manager");

         //release the business service
         m_busServ.release();
         System.out.println("BS released ");

         //release the business component
         m_busComp.release();

         System.out.println("BC released ");

         //release the business object
         m_busObject.release();
         System.out.println("BO released ");

         // logoff
         m_dataBean.logoff();
         System.out.println("Logged off the Siebel Server ");
      }

      catch (SiebelException e)
      {
         System.out.println(e.getErrorMessage());
      }

   }

}

For more information, see Logoff Method for an Application.

SetFieldValue Method for a Business Component

The SetFieldValue method sets a new value for a field in the current record of a business component. This method does not return any information.

Format

BusComp.SetFieldValue FieldName, FieldValue

Table 67 describes the arguments for the SetFieldValue method.

Table 67. Arguments for the SetFieldValue Method
Argument
Description

FieldName

String that contains the name of the field.

FieldValue

String that contains the value to set.

The format for the FieldName argument uses the same format that is described in Format for the ActivateField Method.

The length of the FieldValue argument must not exceed the length of the field. For example, if you pass a 20 character string to a field that is defined as 16 characters in length, then Siebel CRM creates a run-time error that is similar to the following:

Value too long for field 'xxxxx' (maximum size nnn).

You must make sure the length of the string you pass is no longer than the length of the destination field.

Usage

You can use the SetFieldValue method only on a field that is active. For more information, see ActivateField Method for a Business Component.

If the Siebel application runs in standard interactivity mode, then call the WriteRecord method and write the record immediately after you use the SetFieldValue method.

You cannot use the SetFieldValue method with a calculated field. You cannot use the SetFieldValue method recursively.

Used With

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

Examples

The following example is in Siebel VB:

If Val(Me.GetFieldValue("Rep %")) < 75 Then
   Me.SetFieldValue "Rep %", "75"
   Me.WriteRecord
End If

The following is the equivalent example in Siebel eScript:

if (ToInteger(this.GetFieldValue("Rep %")) < 75)

{
this.SetFieldValue("Rep %", "75");
this.WriteRecord();
}

The following Siebel VB example sets a field to null:

oBC.SetFieldValue "FieldName", ""

SetFormattedFieldValue Method for a Business Component

The SetFormattedFieldValue method sets a new value in a field in the current record of a business component. It accepts the field value in the current local format. This method does not return any information.

Format

BusComp.SetFormattedFieldValue FieldName, FieldValue

The arguments you can use this format are the same as the arguments described in Table 67.

Usage

The SetFormattedFieldValue method is useful if you write code for a Siebel application that you deploy in multiple countries that use different currency, date, and number formats.

You can use the SetFormattedFieldValue method only on a field that is active. For more information, see ActivateField Method for a Business Component.

Used With

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

Examples

The following Siebel VB example is a fragment from a program that tracks the progress of an opportunity through sales stages:

Function BusComp_PreWriteRecord As Integer

Dim OpportunityBO as BusObject, StageBC as BusComp
Dim OppStageId as String, SalesRep as String, Stage as String
Dim StagePrev As String, StageDate as String, StageDatePrev as String
Dim Dx as Double, Dy as Double, Diff as Double, DiffStr as String
Dim OppID As String, OppStageId as String, StageID As String
Dim SalesStageBO as BusObject, SalesStageBC as BusComp

Set OpportunityBO = TheApplication.GetBusObject ("Opportunity")
Set SalesStageBO = TheApplication.GetBusObject ("Sales Cycle Def")
Set SalesStageBC = SalesStageBO.GetBusComp("Sales Cycle Def")

With SalesStageBC
   .SetViewMode AllView
   .ClearToQuery
   .SetSearchSpec "Sales Cycle Stage", StagePrev
   .ExecuteQuery ForwardOnly
   If (.FirstRecord) Then
      StageId = .GetFieldValue("Id")
End With

'Instantiate stage BC
Set StageBC = OpportunityBO.GetBusComp("Opportunity Stage")

'Check that we do not already have a record for the stage

   With StageBC
      .SetViewMode AllView
      .ClearToQuery
      .SetSearchSpec "Sales Stage Id", StageId
      .ExecuteQuery ForwardOnly

'Proceed further only if we do not already have record
'opportunity sales stage

      If (.FirstRecord = 0) Then
         'Create a new stage record and write it out
            .NewRecord NewAfter
            'Record Id for future use
            OppStageId = .GetFieldValue("Id")
            .SetFieldValue "Opportunity Id", OppId
            .SetFieldValue "Sales Stage Id", StageId
            .SetFieldValue "Sales Rep", SalesRep
            .SetFormattedFieldValue "Entered Date", StageDatePrev
            .SetFormattedFieldValue "Left Date", StageDate
            Dx = DateValue (StageDatePrev)
            Dy = DateValue (StageDate)
            Diff = Dy - Dx
            DiffStr = Str(Diff)
            .SetFieldValue "Days In Stage", DiffStr
            .WriteRecord
      End If
   End With

Set SalesStageBC = Nothing
Set SalesStageBO = Nothing
Set StageBC = Nothing
Set OpportunityBO = Nothing

End Function

SetMultipleFieldValues Method for a Business Component

The SetMultipleFieldValues method sets new values in the fields of the current record of a business component. This method does not return any information.

Format

BusComp.SetMultipleFieldValues oPropertySet

Table 68 describes the arguments for the SetMultipleFieldValues method.

Table 68. Arguments for the SetMultipleFieldValues Method
Argument
Description

oPropertySet

Property set that identifies a collection of properties. This argument identifies the fields to set and the value to set for each field.

The FieldName argument in the property set must match exactly the field name in Siebel Tools, including the correct case. In the following example, the FieldName is Name and the FieldValue is Acme:

oPropertySet.SetProperty "Name","Acme"

Usage

You can use the SetMultipleFieldValues method only on a field that is active.

Do not use the SetMultipleFieldValues method on a field that uses a picklist.

Used With

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

Examples

The following example is in Siebel eScript:

var bo = TheApplication().GetBusObject("Opportunity");
var bc = bo.GetBusComp("Opportunity");
var ps = TheApplication().NewPropertySet();

with (ps)
{
   SetProperty ("Name", "Call Center Opportunity");
   SetProperty ("Account", "Marriott International");
   SetProperty ("Sales Stage", "2-Qualified");
}

bc.ActivateMultipleFields(ps);
bc.NewRecord(NewBefore);
bc.SetMultipleFieldValues(ps);
bc.WriteRecord;

ps = null;
bc = null;
bo = null;

The following Siebel Java Data Bean example sets multiple fields:

SiebelDataBean      Sieb_dataBean    = null;
SiebelBusObject     Sieb_busObject   = null;
SiebelBusComp       Sieb_busComp     = null;
SiebelPropertySet     ps                = null;

try {

Sieb_dataBean = new SiebelDataBean();
...
Sieb_busObject = Sieb_dataBean.getBusObject("Account");
Sieb_busComp = Sieb_busObject.getBusComp("Account");
ps = Sieb_dataBean.newPropertySet();

with(ps) {

setProperty("Name", "Frank Williams Inc");
setProperty("Location", "10 Main St");
setProperty("Account Status", "Active");
setProperty("Type", "Customer");

}

Sieb_busComp.activateField ("Name");
Sieb_busComp.activateField ("Location");
Sieb_busComp.activateField ("Account Status");
Sieb_busComp.activateField ("Type");

Sieb_busComp.newRecord(true);
Sieb_busComp.setMultipleFieldValues(ps);
Sieb_busComp.writeRecord();

}

catch (SiebelException e) {

system.out.println("Error : " + e.getErrorMessage());

}

ps.release();
Sieb_busComp.release();
Sieb_busObject.release();
Sieb_dataBean.release();

Related Topics

For more information, see the following topics:

SetNamedSearch Method for a Business Component

The SetNamedSearch method sets the named search specification on a business component. This method does not return any information.

Format

BusComp.SetNamedSearch searchName, searchSpec

Table 69 describes the arguments for the SetNamedSearch method.

Table 69. Arguments for the SetNamedSearch Method
Argument
Description

searchName

String that identifies the name of the search specification.

searchSpec

String that contains the search specification.

The searchSpec argument works in the same way as the argument you use after the equal sign in a predefined query. For more information, see SetSearchExpr Method for a Business Component and SetSearchSpec Method for a Business Component.

Usage

A named search specification is a type of search specification that Siebel CRM applies in conjunction with the existing search specification. It applies the named search specification every time it calls the ExecuteQuery method. For example, with a predefined query or with the search specification on a business component.

You can only modify a named search specification programmatically. You cannot use the administrative interface to modify a named search specification.

The ClearToQuery method does not clear the named search specification. To clear it, you must explicitly set the searchSpec argument to "". If Siebel CRM creates a new instance of a business component, then it clears the named search specification.

Using the SetNamedSearch method to define a search does not create a predefined query. You specify this search only in script. To return this search specification, you can use the GetNamedSearch method. To return the values of an attribute in a user profile, Personalization uses the GetProfileAttr method.

Used With

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

Examples

The examples in this topic set a named search specification for a business component depending on the position of the current user.

The following example is in Siebel eScript:

function BusComp_PreQuery ()
{
   if (TheApplication().GetProfileAttr("Position") == "Siebel Administrator");
   {
      this.SetNamedSearch ("Candidates", "[Status] LIKE 'Candidate'")
   }

   return (ContinueOperation);
}

The following example is in Siebel VB:

Function BusComp_PreQuery () As Integer
   If TheApplication.GetProfileAttr("Position") = "Siebel Administrator" Then
      Me.SetNamedSearch "Candidates", "[Status] LIKE 'Candidate'"
End If

BusComp_PreQuery = ContinueOperation
End Function

SetSearchExpr Method for a Business Component

The SetSearchExpr method sets a search expression for a business component. This method does not return any information.

Format

BusComp.SetSearchExpr searchSpec

Table 70 describes the arguments for the SetSearchExpr method.

Table 70. Arguments for the SetSearchExpr Method
Argument
Description

searchSpec

String that identifies the search specification.

Usage

You can call the SetSearchExpr method after you call the ClearToQuery method and before you call the ExecuteQuery method. It is not necessary to use the ActivateField method on a field that you specify in the SetSearchExpr method.

The maximum length of a predefined query is 2000 characters.

The searchSpec argument works in the same way as the argument you use after the equal sign in a predefined query. For example, consider the following predefined query:

'Account'.Search = "[Name] ~ LIKE ""A. C. Parker"" "

You can use the following equivalent search specification in various interface methods:

BC.SetSearchExpr "[Name] ~ LIKE ""A. C. Parker"" "

In this example, Name is a field in a business component. You must enclose it in square brackets, [ ].

To create a query that includes a sort specification, use the SetSortSpec method. You cannot use the SetSearchExpr method to set a sort specification. Do not use the SetSearchExpr method and the SetSearchSpec method together. These methods are mutually exclusive.

Any date you use with the SetSearchExpr method must use the MM/DD/YYYY format, regardless of the Regional control panel settings on the Siebel Server or the Siebel client.

Using the SetSearchExpr Method with a Keyword

If a field value contains a search keyword, then you must use two pairs of double quotes around the field value. Example keywords include NOT, AND, or OR. For example, if the Sub-Status field includes the string Not an Issue as a field value, then you must use the following Siebel VB format to avoid an SQL error:

substatus = GetFieldValue("Sub-Status")
searchst = "[Value] = """ & substatus & """""
BC.SetSearchExpr searchst

The following Siebel VB format creates an SQL error:

substatus = GetFieldValue("Sub-Status")
searchst = "[Value] = " & substatus
BC.SetSearchExpr searchst

Used With

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

Examples

The following example in Siebel eScript demonstrates how to log the current search specification to a file:

var Ob = TheApplication().ActiveBusObject();
var BC = Ob.GetBusComp("Opportunity");
var Account = "Turston Steel";
var Oppty = "CAD/CAM implementation";
var searchst = "[Name] = '" + Oppty + "' AND [Account] = '" + Account + "'";

TheApplication().TraceOn("c:\\temp\\trace.txt", "Allocation", "All");
TheApplication().Trace("the search expression is: " + searchst);
BC.ClearToQuery();
BC.SetSearchExpr(searchst);
BC.ExecuteQuery(ForwardBackward);

Related Topics

For more information, see the following topics:

SetSearchSpec Method for a Business Component

The SetSearchSpec method sets the search specification for a business component. This method does not return any information.

CAUTION:  Do not use the SetSearchExpr method and the SetSearchSpec method together. They are mutually exclusive.

Format

BusComp.SetSearchSpec FieldName, searchSpec

Table 71 describes the arguments for the SetSearchSpec method.

Table 71. Arguments for the SetSearchSpec Method
Argument
Description

FieldName

String that identifies the name of the field where Siebel CRM sets the search specification.

searchSpec

String that contains the search specification.

Usage

You must call the SetSearchSpec method before you call the ExecuteQuery method.

To avoid an unexpected compound search specification on a business component, it is recommended that you call the ClearToQuery method before you call the SetSearchSpec method. It is not necessary to use the ActivateField method on a field that you reference in the SetSearchSpec method.

Making Multiple Calls to the SetSearchSpec Method

If you instruct Siebel CRM to make multiple calls to the SetSearchSpec method for a business component, then it handles the multiple search specifications in the following ways:

  • If the existing search specification is on the same field as the new search specification, then Siebel CRM replaces the existing search specification with the new search specification. For example, consider the following code:

    myBusComp.SetSearchSpec("Status", "<> 'Renewal'");
    myBusComp.SetSearchSpec("Status", "<> 'Dropped'");

    This code results in the following WHERE clause:

    WHERE Status <> 'Dropped'

  • If the existing search specification is not on the same field as the new search specification, then Siebel CRM creates a search specification that is a logical AND of the existing and the new search specifications. For example:

    myBusComp.SetSearchSpec("Type", "<> 'Renewal'");
    myBusComp.SetSearchSpec("Status", "<> 'Sold' AND [Status] <> 'Cancelled' AND [Status] <> 'Renewed'");

    This code results in the following WHERE clause:

    WHERE Type <> 'Renewal' AND (Status<> 'Sold' AND Status <> 'Cancelled' AND Status <> 'Renewed')

  • If the existing search specification includes one or more of the same fields as the new search specification, then Siebel CRM replaces only that part of the existing search specification that includes fields that the new search specification also includes. For example:

    myBusComp.SetSearchSpec("Status", "<> 'In Progress'")

    This code results in the following WHERE clause:

    WHERE Type <> 'Renewal' AND Status <> 'In Progress'

    Siebel CRM replaces the search specification only on the Status field.

Combining Declarative and Scripted Search Specifications

If you define a search specification declaratively in Siebel Tools, and if you use the SetSearchSpec method to define another search specification in script, then Siebel CRM creates a search specification that is a logical AND of the declarative search specification and the scripted search specification. For example, consider the following scripted search specification:

myBusComp.SetSearchSpec("Status", "<> 'Cancelled'")

Consider the following declarative search specification:

[Type] <> 'Renewal' AND [Status] <> 'Sold'

When Siebel CRM creates a logical AND between these search specifications, the following WHERE clause results:

WHERE Type <> 'Renewal' AND (Status <> 'Sold' AND Status <> 'Cancelled')

Using Logical and Comparison Operators in a Search Specification

You can use logical operators and comparison operators. Consider the following example, in Siebel VB:

BC.SetSearchSpec "Status", "<> 'Closed' AND ([Owner] = LoginName () OR [Refer To] = LoginName ()) OR ([Owner] IS NULL AND [Support Group] = 'TS-AE')"

Using Special Characters in a Search Specification

The search specification can contain any of the following special characters:

  • " (double quote)
  • ' (single quote)
  • = (equal sign)
  • > (greater than symbol)
  • < (less than symbol)
  • ( (opening parenthesis)
  • ) (closing parenthesis)
  • [ (opening square bracket)
  • [ (closing square bracket)
  • , (comma)
  • ~ (tilde)

You must enclose each of these special characters in quotes. This rule applies to operators that are part of the search expression and to the search text.

Using Quotes and Other Characters in a Search Specification

If the search expression contains quotes or another special character, then you must enclose the entire search specification in double quotes. An apostrophe is an example of a special character.

If the search object includes a special character, then you must double that character. For example, assume your specification must search for text that contains a single double quote:

"We must

In this situation, you must do the following work:

  1. Use two double quotes before the word We:

    ""We must

  2. Enclose the string you created in Step 1 with single quotes:

    '""We must'

  3. Enclose the entire expression in double quotes:

    "'""We must'"

  4. Add the expression to the search specification:

    SetSearchSpec "Comments", "'""We must'"

In another example, assume your search specification must search for the following text in the Name field:

Phillie's Cheese Steaks

In this situation, you must use the following search specification:

SetSearchSpec "Name", "'Phillie''s Cheese Steaks'"

Using Quotes and Other Characters in a Search Specification in Siebel eScript or Browser Script

To mark a special character in Siebel eScript or Browser Script, you must use a backslash instead of a double quote. For example:

  • To include double quotes before the word We, you must use the following format:

    SetSearchSpec("Comments", "\'\"We must\'")

  • To include the string Phillie's Cheese Steaks, you must use the following format:

    SetSearchSpec("Name", "\'Phillie\'\'s Cheese Steaks\'")

For more information, see Using Quotes and Other Characters in a Search Specification.

Using a Search Specification to Search Text in a Nontext Field

If any of the following situations are true, then you must use double quotes to enclose the text you use in a search specification:

  • The search expression queries a field of any type other than a text field.
  • The search expression includes any character that is not included in the following list:
    • Any upper-case letter of the alphabet. For example:

      ABCDEFGHIJKLMNOPQRSTUVWXYZ

    • Any lower-case letter of the alphabet. For example:

      abcdefghijklmnopqrstuvwxyz

    • Any of the following special characters:
      • underscore (_)
      • question mark (?)
      • back slash (\)
      • double quote (")
      • single quote (')
      • opening bracket ([)
      • closing bracket (])
Using a Search Specification to Return All Records

To return all records, use the ClearToQuery method and then the ExecuteQuery method. Do not use the SetSearchSpec method. For more information, see ClearToQuery Method for a Business Component and ExecuteQuery Method for a Business Component.

Using a Search Specification to Search for a Null Field

To search for a null field, use the following form:

SetSearchSpec "Account", "is NULL"

If your search specification requests an empty string, then the search returns every record. For example:

SetSearchSpec "Account", ""

Used With

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

Examples

The following Siebel VB code searches for a contact by name, and then navigates to a view that displays this record:

(general)
(declarations)
Option Explicit

Sub Button1_Click
Dim theCurrComp As BusComp
Dim TargetView As String
Dim TargetBusObj As String
Dim TargetBusComp As String
Dim NewBusObj As BusObject
Dim NewComp As BusComp
Dim RecId1 As String
Dim RecId2 As String
Dim RecId3 As String

TargetView = "Visible Contact List View"
TargetBusObj = "Contact"
TargetBusComp = "Contact"
Set theCurrComp = Me.BusComp
RecId1 = theCurrComp.GetFieldValue("Last Name")
RecId2 = theCurrComp.GetFieldValue("First Name")
RecId3 = theCurrComp.GetFieldValue("Account Id")
Set NewBusObj = TheApplication.GetBusObject(TargetBusObj)
Set NewComp = NewBusObj.GetBusComp(TargetBusComp)
NewComp.ClearToQuery
NewComp.SetSearchSpec "Last Name", RecId1
NewComp.SetSearchSpec "First Name", RecId2
NewComp.SetSearchSpec "Account Id", RecId3
NewComp.ExecuteQuery ForwardBackward

TheApplication.GotoView TargetView , NewBusObj

Set NewComp = Nothing
Set NewBusObj = Nothing
Set theCurrComp = Nothing

End Sub

For other Siebel VB examples, see FirstRecord Method for a Business Component, SetFormattedFieldValue Method for a Business Component, and BusComp_PreQuery Event.

The following example is in Siebel eScript:

var oAccntBO = TheApplication().GetBusObject("Account");
var oAccntBC = oAccntBO.GetBusComp("Account");
var oAddrBC;

with (oAccntBC)
{
   SetViewMode(SalesRepView);
   ClearToQuery();
   SetSearchSpec("Name", "Hong Kong Flower Shop");
   ExecuteQuery(ForwardBackward);

   if (FirstRecord())

oAddrBC = GetMVGBusComp("Street Address");
with (oAddrBC)
{
   NewRecord(NewAfter);
   SetFieldValue("City", "Denver");
   SetFieldValue("Street Address", "123 Main Street");
   WriteRecord();
}

}

oAddrBC = null;
oAccntBC = null;
oAccntBO = null;

For another Siebel eScript example, see ClearToQuery Method for a Business Component.

SetSortSpec Method for a Business Component

The SetSortSpec method sets the sort specification for a business component. This method does not return any information.

Format

BusComp.SetSortSpec sortSpec

Table 72 describes the arguments for the SetSortSpec method.

Table 72. Arguments for the SetSortSpec Method
Argument
Description

sortSpec

String that contains the sort specification.

The sortSpec argument uses the following format:

"fieldName1,fieldName2,...(ASCENDING)"

or

"fieldName1,fieldName2,...(DESCENDING)"

You must enclose the entire string in double quotes. To sort on various fields in different orders, you can use a comma to separate field names and order specifications.

Usage

If you use the SetSortSpec method, then you must call it after you call the ClearToQuery method and before you call the ExecuteQuery method.

The SortSpec argument works in the same way as the equal sign in a predefined query. For example, consider the following predefined query:

'Account'.Sort = "Name(ASCENDING)"

You can use the following equivalent search specification in various interface methods:

BC.SetSortSpec "Name(ASCENDING)"

Note that Name is the value in the Name property of the business component field. This example queries the Name field.

Any date you use with the SetSortSpec method must use the MM/DD/YYYY format, regardless of the Regional control panel settings of the Siebel Server or Siebel client.

Used With

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

Examples

The Siebel VB example in this topic sorts the Opportunity list first by Account in reverse order, and then in alphabetical order by Site. Note that the column names in the Opportunity list applet are not the same as the names in the underlying business component.

For demonstration purposes, this example sorts in ascending and descending order. In actual practice, do not sort in two directions in a single sort specification because this type of sorting can significantly degrade performance.

Function BusComp_PreQuery As Integer

With Me
   .ActivateField("Account")
   .ActivateField("Account Location")
   .ClearToQuery
   .SetSortSpec "Account(DESCENDING), Account Location(ASCENDING)"
   .ExecuteQuery ForwardBackward
End With

End Function

The following is the equivalent example in Siebel eScript:

function BusComp_PreQuery {

with (this)
{
   ActivateField("Account");
   ActivateField("Account Location");
   ClearToQuery();
   SetSortSpec("Account(DESCENDING), Account Location(ASCENDING)");
   ExecuteQuery(ForwardBackward);
}

}

Related Topics

For more information, see the following topics:

SetUserProperty Method for a Business Component

The SetUserProperty method sets the value of a user property in a business component. A user property is similar to an instance variable of a business component. This method does not return any information.

Format

BusComp.SetUserProperty propertyName, newValue

Table 73 describes the arguments for the SetUserProperty method.

Table 73. Arguments for the SetUserProperty Method
Argument
Description

propertyName

String that identifies the name of the user property.

newValue

String that contains the new value.

Usage

Usage for the SetUserProperty method is similar to the usage for the GetUserProperty method. For more information, see Usage for the GetUserProperty Method.

Used With

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

Examples

The following example is in Siebel VB:

Sub BusComp_SetFieldValue (FieldName As String)
   Select Case FieldName
      Case "Committed"
         me.SetUserProperty "Flagged", "Y"
   End Select
End Sub

The following is the equivalent example in Siebel eScript:

function BusComp_SetFieldValue (FieldName)
{
   switch (FieldName)
   {
      case "Committed":
         this.SetUserProperty("Flagged", "Y");
   }
}

SetViewMode Method for a Business Component

The SetViewMode method sets the visibility type for a business component. This method does not return any information. For more information, see GetViewMode Method for a Business Component.

Format

BusComp.SetViewMode mode

Table 74 describes the arguments for the SetViewMode method.

Table 74. Arguments for the SetViewMode Method
Argument
Description

mode

A Siebel ViewMode constant or the corresponding integer value for the constant. For more information, see Constants You Can Use with the SetViewMode Method.

Siebel ViewMode constants correspond to applet visibility types. For more information about applet visibility types, see Siebel Security Guide.

Constants You Can Use with the SetViewMode Method

Table 75 describes the constants you can use with the SetViewMode method. The Owner Type column indicates the value that must be set in the Owner Type property of the BusComp view mode object of the business component. For more information, see Use Constants to Standardize Code.

Table 75. Constants for the SetViewMode Method
Siebel ViewMode Constant
Integer Value
Owner Type
Description

SalesRepView

0

Position

This constant does the following:

  • Applies access control according to a single position or a sales team.
  • Displays records according to one of the following items:
    • The user position.
    • The sales team that includes the user position. The Visibility field or Visibility MVField of the business component determines the visibility.

ManagerView

1

Position

Displays records that the user and the users who report to the user can access. For example, the records that Siebel CRM displays in the My Team's Accounts visibility filter.

If the business component that the view references uses single position access control, then this constant displays records that Siebel CRM associates directly with the active position of the user and with subordinate positions.

If the business component that the view references uses sales team access control, then this constant displays records according to one of the following positions:

  • The primary position for the user on a team.
  • A subordinate position that is the primary member on a team.

If the user position does not include a subordinate position, then Siebel CRM does not display any records.

PersonalView

2

Position

Displays records that the user can access, as determined by the Visibility Field property of the BusComp view mode object. For example, the records that Siebel CRM displays in the My Accounts visibility filter.

AllView

3

Not applicable

Displays all records that includes valid owner. For example, the records that Siebel CRM displays in the All Accounts Across Organizations visibility filter.

OrganizationView

5

Position

Displays records where a valid owner is associated with the record and the user position is associated with the organization. For example, the records that Siebel CRM displays in the All Accounts List View visibility filter.

Applies access control for a single organization or for multiple organizations, as determined by the Visibility field or Visibility MVField of the BusComp view mode object of the business component.

GroupView

7

Not applicable

This constant does one of the following:

  • Displays a list of the subcategories that the user can access.
  • Displays records in the current category, depending on the current applet. If the user is at the catalog level, then Siebel CRM displays the first level categories.

CatalogView

8

Catalog Category

Displays a list of records in categories across every catalog that the user can access. Siebel CRM typically uses this visibility in a product picklist and other list of products, such as a recommended product list.

SubOrganizationView

9

Organization

If the business component that the view references uses single organization access control, then this constant displays records that Siebel CRM associates directly with one of the following organizations:

  • The organization that is currently active for the user.
  • A descendent organization. This descendent organization is part of the organization hierarchy.

For example, the records that Siebel CRM displays in the All Opportunities Across My Organization visibility filter.

If the business component that the view references uses multiple organization access control, then this constant displays records for the primary active organization or for the primary descendent organization.

Used With

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

Examples

The following example is in Siebel VB. For another example, see BusComp_PreDeleteRecord Event:

(general)
(declarations)
Option Explicit
Dim oBO as BusObject
Dim oBC as BusComp

Set oBO = TheApplication.GetBusObject(Me.BusObject.Name)
Set oBC = oBO.GetBusComp(Me.Name)
With oBC
   .SetViewMode SalesRepView
   .ClearToQuery
   .SetSearchSpec "Name", Me.GetFieldValue("Name")
   .SetSearchSpec "Id", "<> " & Me.GetFieldValue("Id")
   .ExecuteQuery ForwardOnly
   If .FirstRecord Then
      TheApplication.Trace"Entry for name " & Me.GetFieldValue("Name") & " exists."
   End If
End With

Set oBC = Nothing
Set oBO = Nothing

The following is the equivalent example in Siebel eScript:

var oBO = TheApplication().GetBusObject(this.BusObject().Name());
var oBC = oBO.GetBusComp(this.Name);

TheApplication().TraceOn("c:\\trace.txt","Allocation","All");
with (oBC)
{
   SetViewMode(SalesRepView);
   ClearToQuery();
   SetSearchSpec("Name", this.GetFieldValue("Name"));
   SetSearchSpec("Id", "<> " + this.GetFieldValue("Id");
   ExecuteQuery(ForwardOnly);
   if (FirstRecord())
      TheApplication().Trace("Entry for name " + this.GetFieldValue("Name") + " exists.");
}

TheApplication().TraceOff();
oBC = null;
oBO = null;

UndoRecord Method for a Business Component

The UndoRecord method reverses any unsaved modifications that Siebel CRM has made on a record. This includes reversing unsaved modifications to fields, and deleting an active record that is not saved to the Siebel database. This method does not return any information.

Format

BusComp.UndoRecord

No arguments are available.

Usage

You can use the UndoRecord method in the following ways:

  • To delete a new record. Use it after Siebel CRM calls the NewRecord method and before it saves the new record to the Siebel database.
  • To reverse modifications made to field values. Use it before Siebel CRM uses the WriteRecord method to save these modifications, or before the user steps off the record.

UndoRecord reverses unsaved modifications to a record. If you require a fine degree of control over the modifications that Siebel CRM reverses, then do the following:

  1. Place the code in one of the following events:
    • PreNewRecord
    • PreSetFieldValue
    • PreWriteRecord
  2. Issue a CancelOperation to cancel the modifications that the event calls.

For more information, see Caution About Using the Cancel Operation Event Handler and NewRecord Method for a Business Component.

Used With

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

WriteRecord Method for a Business Component

The WriteRecord method saves to the Siebel database any modifications made to the current record. This method does not return any information.

Format

oBusComp.WriteRecord

No arguments are available.

Usage

After creating new records and setting values for fields, you can call the WriteRecord method to save the new record to the Siebel database.

Used With

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

Examples

The Siebel VB example in this topic implements the following logic: if the user sets the Sales Stage field to 02, then insert an activity:

(general)
(declarations)
Option Explicit

Sub BusComp_SetFieldValue (FieldName As String)
   ' Run this code from the Opportunities Activities view.
   ' Opportunity is presumed to be the parent business component.

   Select Case FieldName
      Case "Sales Stage"
      if Me.GetFieldValue(FieldName) LIKE "02*" Then
         ' reference the Action business component
         Dim oBCact as BusComp
         Set oBCact = me.BusObject.GetBusComp("Action")
         With oBCact
            .NewRecord NewAfter
            .SetFieldValue "Type", "Event"
            .SetFieldValue "Description", "THRU SVB, Stage _
               changed to 02"
            .SetFieldValue "Done", Format(Now(), _
               "mm/dd/yyyy hh:mm:ss")
            .SetFieldValue "Status", "Done"
            .WriteRecord
         End With
         set oBCact = Nothing
      end if
   End Select
End Sub

For more examples, see GetMVGBusComp Method for a Business Component and NewRecord Method for a Business Component

Siebel Object Interfaces Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.