Monday, September 3, 2012

Siebel Scripting Best Practices

In this blog will be covering few best practices while writing eScript.

  • Use ActivateField after ClearToQuery and prior to ExecuteQuery.  ActivateField has a performance impact, if not defined as per above rule it triggers a second Select Query. For example

BC.ClearToQuery();
BC.ActivateField(“”);
BC.ActivateField(“”);
BC.ExecuteQuery();

  • Always use ‘ForwardOnly‘ after the ‘ExecuteQuery’ to set the cursor position, unless moving back through the returned records. It improves performance tremendously as it does not create a cache to stores the previous records. Do not use ForwardOnly when operating on UI business components unless the application code requeries using a cursorMode of ForwardBackward.

ExecuteQuery(“ForwardOnly”);
  • Use ‘with’ when operations are performed within the same business components. It makes it faster in terms of performance and more readable.For example

with(BC)
   {
      SetViewMode(SalesRepView);
      ActivateField("Sales Stage");
      SetSearchSpec("Id", srowid);
      ExecuteQuery(ForwardOnly);
   }
  • Use the ‘Try/Catch/Finally’ statements in code. It will ensure that exceptions are caught and handled appropriately and instantiated object variables are always destructed (in the reverse order they were instantiated.) in the finally block to avoid any memory leaks.
  • Prefer to use ‘Switch Case’ statements rather than using multiple if Else statements.
  • Use of commands like ‘GetMVGBusComp’, GetPickListBusComp’,  ‘GetParentBusComp to access the records, instead of re-querying to retrieve records.
  • Delete all ‘empty’ scripts written on events including the function header and footer. It will avoid the application to go to that script when the event is triggered and performance will be improved slightly.

No comments:

Post a Comment