Siebel eScript Coding Best Practices Cheat Sheet
April 29, 2008 – 11:38 amThe following is the Siebel eScript cheat sheet that I use on my current Siebel project. I ensure that all my developers have a copy of this cheat sheet printed out and posted up near their desk to ensure they adhere to the project Siebel coding standards.
1. Each script should contain a descriptive header providing an overview of the purpose of the function.
2. Always remember to fill-up the revision history section of the code when you update the code. Also, add line or block comments on the part where the change or update was made.
3. Declare all variables at the top of the code above the try statement.
4. String variables must be initialized using and equal sign and two double quotes(“”). Numerical variables on the other hand are initialized by equating it to zero.
5. Use ActivateField for all fields that are not Force Active which will be used in the filter for the search expression or field value will be retrieved after ExecuteQuery. ActivateField should NOT be used with ‘this’.
6. Use proper tabbing in coding for readability. Code should be indented following the logical structure, so that all the statements in the same logical level are in the same indentation.
7. Use InvokeMethod(“SetAdminMode”,”TRUE”) to ensure that all records will be returned.
8. Use with statement when using many functions from an object this provides a performance improvement and presents the code better.
9. Ensure to pass ForwardOnly to the ExecuteQuery function for performance purposes if records do not require deleting after the query has been made.
10. Ensure a FirstRecord() function exists after the ExecuteQuery to verify records returned.
11. If 2 or more else conditions in an if-else clause use a switch statement for performance reasons
12. Place comment within the code so others will be able to easily understand the functions of the codes sections.
13. In the catch statement always raise the error using TheApplication().RaiseErrorText.
14. Single function return statement outside the Try/Catch/Finally clause.
15. All object type variables should be released in the finally clause. Objects should be released in the reverse order they were initialized.

6 Responses to “Siebel eScript Coding Best Practices Cheat Sheet”
Thanks for this cheat sheet, this was very useful..
By Mouhammad on May 1, 2008
Hi Mouhammad….. U don good job………..it’s more usefull to my Carrier grouth…. but i want some more details regarding Scripting…… can U explain how to start writing scripting….. can U explain with small example…ple let me help…
Thanks
Siva
By Siva on Jun 18, 2008
Please post questions on the Siebel Answers forum:
http://forum.siebelanswers.com/
A small example of scripting is to write some validation when a record is saved. So you would save a contact record then you could write some code on Contact business component PreWriteRecord event to check that the date of birth is entered as this field is required:
try {
if (this.GetFieldValue(”Birth Date”) == “”)
{
throw(”Birth Date is required. “);
}
} catch(e)
{
TheApplication().RaiseErrorText(e.toString());
}
This is a simple example of eScript within Siebel.
By Josh on Jun 21, 2008
Hi Josh… I am very happy to U’R replay…..
At The same manner i want W/F.. i have little bit of Knowledge in W/F but i want know in which swuchivation using Policy’s and Runtime event’s and scripting……. ple give replay.. i waiting for U’R replay..
Thanks
Gopi
By Siva on Jun 23, 2008
OH HAI JOSH
By Subby on Aug 21, 2008
lol hello Subzor
By Program on Aug 21, 2008