Skip to main content
  1. Posts/

Siebel User Defined Objects

·2 mins

Ever missed all the OOP goodness in Siebel? Although not used frequently, user defined objects provide you with some degree of control in hiding complexities in scripting. No, this will not help you attain OO nirvana - but you can start doing things with the custom objects and prototyping to:

  • Hide complexity
  • Provide scalability
  • Save memory while doing the above

Here’s a simple example that demonstrates use of user-defined objects. To test, you simply copy the code in a new client business service and you are all set.

First the Service_PreInvoke method:


function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var qryBC;

qryBC = new GetRecord("Contact", "Contact", "[Id] = '0-1'", "First Name", "Last Name");

Outputs.SetProperty("First Name", qryBC.Values[3]);
Outputs.SetProperty("Last Name", qryBC.Values[4]);

return (CancelOperation);
qryBC = null;
}
```


Next comes the constructor:

```js

function GetRecord ()
{
try {

var arrValue = new Array();
var iCount;

if (arguments.length < 4) TheApplication().RaiseErrorText("I need minimum four arguments - BO name, BC name, SearchExpr and at least one field name.");

var bo = TheApplication().GetBusObject(arguments[0]);
var bc = bo.GetBusComp(arguments[1]);

with (bc){
    ClearToQuery();
    SetViewMode(AllView);
    SetSearchExpr(arguments[2]);
    for (iCount = 3; iCount < arguments.length; iCount++){
        ActivateField(arguments[iCount]);
    }
    ExecuteQuery(ForwardOnly);
}

if (bc.FirstRecord()) {
    for (iCount = 3; iCount < arguments.length; iCount++){
        arrValue[iCount] = bc.GetFieldValue(arguments[iCount]);
    }
}
this.Values = arrValue;
} // try

catch(e){
    throw(e);
}

finally{
    arrValue = null;
    bc = null;
    bo = null;
}
}
```


The explanation follows:

###### **Purpose**

Provide ability to query any given BO / BC and retrieve the specified field values

###### <strong style="font-size: 15px;">How did we do that?</strong>

First, we create an object called “qryBC”. This becomes instance of a class “GetRecord” when the constructor “GetRecord()” is executed. At this time we also pass the arguments to the object, whereby the constructor will query and return you the results. For simplicity in further processing, we return an array with the query results. Note the use of ‘this’ in the constructor and the reference to the set values when retrieving results in 'PreInvoke' method. We are just letting the constructor do all the work, but this could span into other functions as well.

A note of caution:

- This way of doing things is more familiar to javascript developers, there is not a whole lot of documentation or examples on how this works within Siebel itself
- Make sure that your maintenance team knows how this script works before you go ahead and implement