Though scripting should be avoided, it is often common that scripting would become necessary to meet our requirements. So if scripted, it should be done the most efficient way. There are several optimization techniques. Below are some and I will post more in the future.
Tip 1:
Avoid repeated calling of a function if the results returned are the same. Instead cache the value in a variable. Especially avoid repeated calling of the API function like TheApplication().ActiveViewName() as shown below.

Tip2:
Delay Object Instantiation. If the object being used is under a conditional expression then wait till the conditional statement actually evaluates true. This reduces the cost and burden on the server. See the code below.

Make sure you leave some comments.
There are more Tips to come. So stay tuned.
Related posts(Auto Generated):





December 3rd, 2007 at 12:55 pm
Can u plz give me More tips Plz
December 27th, 2007 at 6:00 am
Hi Eashwerprasad,
I have been very busy lately, but I will soon have a new post another best practices.
Thanks,
SiebelGuide
September 3rd, 2008 at 12:47 pm
Perfect suggestions in scripting!!! Hats off to your initiation in posting and updating Siebel newbies. Lakshmi
September 3rd, 2008 at 5:09 pm
Hi Lakshmi,
Thanks for your compliments. But please note that participation from people like you is highly needed to share knowledge and learn more.
So I urge all the visitors to write articles on Siebel and send it to me. I will post those over here by crediting your name on it. This way learning becomes easy.
Thanks,
Sridhar
September 26th, 2008 at 4:30 pm
eScripting Best Practices - Part2 bis
Never write:
“ExectuteQuery()” or “ExecuteQuery()”
but :
“ExecuteQuery(ForwardOnly)” or “ExecuteQuery(ForwardBackward)”
don’t forget Try and Finally to release your BO/BC …
September 16th, 2009 at 1:51 pm
hello Mr.sridhar, really very happy to find dis type of site on siebel, very useful to siebelians, Sridhar am having a requirement,i searched almost but didnt find exact solution,can u pls help me out,my req:I want to find the distance between two zipcodes,longitudes n latitudes , thru a table, hope only you can help me out,thanks
September 16th, 2009 at 5:51 pm
For distance between longitude and latitude you can do some calculation. check this link.
http://www.meridianworlddata.com/Distance-Calculation.asp
for distance using zipcode…this is like a big matrix if you ask and you will have to buy third party data for this. (Atleast this is my belief) or use some kind of API to call Google maps..not sure.
September 16th, 2009 at 5:56 pm
There are several websites giving you a formula for finding distance using latitude and longitude. google for it.
scratch my previous comments about zipcode. For zipcodes, all you will have to do is, get the corresponding longitude and longitude and work of that one.
Hope this helps. It is not complicated.
March 30th, 2010 at 11:40 pm
Hi
Can you please write the script
like when user checked the forecase on Revenue line . all the checked forcast should be sum to Revenue field on Opportunity header.