Siebel-eScripting best practices

The following are the few best practices that should be followed while writing eScript.

  1. Implement error handling in eScript using try/catch/Finally mechanism.

Try block: Contains the logic that needs to be performed.

Catch block: Captures the error.

Finally block: Perform the cleanup work such as destroying the objects.

  1. Overuse of variables increases the amount of operations that have to be performed and can reduce performance slightly. Destroy the object variables when no longer needed. When a script creates an object reference, that same script must destroy the object reference before leaving that method. Handle destroying the object variables in finally block.
  2. Remove the unused code from the repository.

4.Use conditional blocks to run the code.

e.g.  The best example for this is BusComp_PreSetFieldValue. The code in this event is associated with a specific field not with all the fields.So check which field the code is modifying, before proceeding further.

function BusComp_PreSetFieldValue (FieldName, FieldValue)

case “Name”:
–Perform the action—
break ;
return (ContinueOperation);

  1. Instead of using multiple ‘if else if’ statement it is better to use ‘Switch Case’ statement. This simplifies code and improves performance.
  2. When performing a query, always use ‘ForwardOnly’ after the ‘ExecuteQuery’ to set the cursor position unless moving back through the returned records. This is a much faster query because it does not create a cache that stores the previous records.
  3. Scripts which insert new records or change data should take care to explicitly commit (i.e WriteRecord() needs to be executed after insertion of new records or change data). the record otherwise the data could be lost.
  4. If a particular code needs to be used in multiples places, instead of writing the code in each and every object/place write the code the business service and call the business service where ever it is required.
  5. The use of ‘With’ is recommended by Siebel as it enables the code to be changed faster and more readable way to group operations performed within the same business component. The use of ‘With’ also presents a slight performance improvement.
  6. The use of ‘ActivateField’ in Siebel scripts code should be minimized as much as possible as this has a performance impact. Use of ‘ActivateField’ shold be prior to ‘ExecuteQuery’.
  •         Siebel system fields (Id, Created, Created By, Last Updated, Last Updated By) are always force active.
  •         Fields that have Force Active = Y on the business component are always force active.
  •         Fields have Link Specification = Y on the business component are always force active.
  •         If the user removes the list column from the ‘Columns Displayed’ in the list applet, the field may no longer be active after the next query.
  •         Hidden list column/controls  are always force active.
  •         Fields that are used as part of a calculated field calculation.
  1. Reduce the number of queries performed as much as possible. Siebel maintains the parent-child relationships defined in links automatically so there is no need to query the child Business Component to obtain records for a given parent. Make use of commands like, ‘GetParentBusComp’ to access the parent record, instead of re-querying to retrieve record.
  2. If ‘BO’ and ’BC’ reference is needed from the current context make use of default application variables ‘BusComp’ and ‘BusObject’ in this situation.
  3. The use of ‘ActiveBusObject’, ‘ActiveBusComp’ and ‘ActiveApplet’ should be limited because the object represented by these statements may change depending on the active applet. Siebel recommends the use of the ‘this’ object for eScript wherever possible.
  4. When you are deleting records in script based on a particular query, be sure to use a while loop rather than an ‘If’ statement as the ‘If’ condition will only delete one record where multiple records may need to be deleted.
  5. All code must be indented logically, including comments which efficiently describe what the script is doing. Each new script should include a header comment which provides: Author, Date, Description and Version History for that script.


Happy reading@Optanium!!!