Example of the Business Object and Business Component Interface
Following is a code sample demonstrating use of the business object API. The sample shows how the Java Data Bean might be used to search for a Contact with a particular login name.
The first step in using the Siebel Java Data Bean is to log in to the Object Manager of the Siebel Server. The first parameter, the connection string, specifies the protocol, server name, enterprise name, and Application Object Manager name. Once logged into the Object Manager, the methods getBusObject and getBusComp are used to obtain business objects and their business components.
The code sample activates fields to allow the query to retrieve data for the specific fields, specifies the search criteria, and executes the query. If the query is successful, then the first and last name of the contact are printed to the standard output.
import com.siebel.data.*;
public class ObjectInterfaceExample {
public static void main(String[] args) throws SiebelException {
String connectString = siebel://examplecomputer:2321/siebel/SCCObjMgr_enu";
SiebelDataBean dataBean = new SiebelDataBean();
dataBean.login(connectString, "USER", "PWD", "enu");
SiebelBusObject busObject = dataBean.getBusObject("Contact");
SiebelBusComp busComp = busObject.getBusComp("Contact");
busComp.setViewMode(3);
busComp.clearToQuery();
busComp.activateField("First Name");
busComp.activateField("Last Name");
busComp.activateField("Id");
busComp.setSearchSpec("Login Name", "thomas");
busComp.executeQuery2(true,true);
if (busComp.firstRecord()) {
System.out.println("Contact ID: " + busComp.getFieldValue("Id"));
System.out.println("First name: " + busComp.getFieldValue("First Name"));
System.out.println("Last name: " + busComp.getFieldValue("Last Name"));
}
busComp.release();
busObject.release();
dataBean.logoff();
}
If the query results in multiple records, then the record set can be iterated as follows:
if (busComp.firstRecord()) {
// obtain the fields/values from this record
while (busComp.nextRecord()){
// obtain the fields/values from the next record
}
}