Professional Documents
Culture Documents
3. Be cautious when adding script to business components as this code applies application wide
across applets and views. If a certain piece of coding is needed at the business component level
but is restrictive to certain situations like if exposed only through some particular views then
make sure to limit the processing through an appropriate condition.
4. The use of µµ 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. is generally used to process a
group of operations on a set of records (on a data record sequentially)
5. Using
can make code maintenance easier due to readability. However overuse of
variables increases the amount of operations that have to be performed and can reduce
performance slightly.
6. Siebel does not recommend the use of µµ. µEmpty¶ is an undefined variable which is
assigned as type variant. A variant is initially set to a null string (´), which means that any scripts
currently using this term will not be affected. However, it is better practice to assign ´ rather than
µEmpty¶ to any strings you need to set back to NULL. The use of µEmpty¶ prevents Option
Explicit from checking all other variables are declared correctly.
7. The use of µ
µ prior to a query is the equivalent to the µSELECT¶ statement in
SQL. The use of µActivateField¶ in Siebel scripts code can be confusing and should be
minimized as much as possible as this has a performance impact. However there is nothing
worse than receiving a runtime exception: µ was not active«¶. When activating fields note that:
a. Siebel system fields (Id, Created, Created By, Last Updated, Last Updated By) are always
force active.
b. Fields that have Force Active = Y on the business component are always force active.
c. Fields that have Link Specification = Y on the business component are always force active.
d. Fields that are included in the definition of an applet on the active view if it is bound to a web
template item and the µShow In List¶ property of the list column or µVisible¶ property of the
control is TRUE. 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.
e. Fields that are used as part of a calculated field calculation when the calculated field is
retrieved for use on the active applet.
8. µ
µ should only be used prior to µ µ to ensure that a particular field
will be activated and included in the equivalent µSELECT¶ statement of the query. Therefore
µActivateField¶ is usually never to be used with µthis¶/'Me¶ (eg. this.ActivateField(µField1ƍ)).
This is because you don¶t usually perform a query in the current context as this would change the
on screen query displayed to the user. Siebel actually specifies that the use of ActivateField with
µthis¶ can possibly cause data corruption to occur.
11. It is best practice in Siebel scripting to use the !%$%
# statements in code. This
will ensure that exceptions are caught and handled appropriately and instantiated object variables
are always destructed in the finally block (which reduces the chances of memory leak) as the
code in the finally block is always executed. Note that object variables should be destroyed in the
reverse order they were instantiated. If the script exists abruptly the memory that is being used to
hold that value might not get released causing memory leak. To avoid any kind memory leak it is
a good practice to null those variables. Common object references that should be set to null are
Business Objects
Property Sets
Business Services
Business Components
Applets
12. 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,
µ& ' c$
µ to access the parent record, instead of re-querying to retrieve record.
13. Don¶t create objects (BC and BOs) if you need a reference to BC and BO from the current
context. Make use of default application variables µBusComp¶ and µBusObject¶ in this situation.
15. 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.
16. Delete all µempty¶ scripts that once contained text. Delete everything, including the function
header and footer. Otherwise the application will go to that script when the event is triggered and
performance will be impacted slightly.
17. Keep use of Applet scripting to a minimum where possible. Attempt to meet business
requirements by configuring in Siebel Tools where possible and generally implementing scripts
for minor functionality where a given functionality cannot be met using declarative
configuration.
18. Scripts which insert new records or change data should take care to explicitly commit the
record otherwise the data could be lost.
19. 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.
(
1: bcPositionMVG.ClearToQuery();
2: bcPositionMVG.InvokeMethod(³SetAdminMode´, ³TRUE´);
3: bcPositionMVG.SetSearchExpr(³[Id] ¶0-5220ƍ´);
4: bcPositionMVG.ExecuteQuery();
5:
6: // The first record is identified and deleted. However,
7: // subsequent child records are not deleted.
8: if ( bcPositionMVG.FirstRecord() )
9: {
10: bcPositionMVG.DeleteRecord();
11: }
Ë(
1: bcPositionMVG.ClearToQuery();
2: bcPositionMVG.InvokeMethod(³SetAdminMode´, ³TRUE´);
3: bcPositionMVG.SetSearchExpr(³[Id] ¶0-5220ƍ´);
4: bcPositionMVG.ExecuteQuery();
5:
6: while ( bcPositionMVG.FirstRecord() )
7: {
8: bcPositionMVG.DeleteRecord();
9: }
)*+c
The main purpose of Siebel Browser script is to extend the functionality of the browser. So
Browser script should be limited to user based events. On the other side Server Side script is
used for data manipulation or anything beyond the capability of the browser.
c
(
(
Access to data beyond the current record. So validate your requirement against this best practice.
As the method name suggests it gets the Business Component of the record that MVG is based
on. This is a very helpful Method that would save a several lines of unnecessary code.
For example, we have Accounts and there are Sales Reps associated to each of these accounts.
These Sales Reps are based on Position BC. Position BC is the MVG Business Component of
Account BC. The requirement is to get all the sales rep associated to the details of all the sales
rep associated to this account using eScript. Now a developer who is writing this eScript and not
aware of this Method would write an eScript something like this.
Get Account Row ID
Get Postion BC
"
/
---------------------------------------------------
oAccBC = oAccBO.GetBusComp("Account");
//Get the corresponding Sales Rep Bus Comp ² eScript Best practice here.
//No Need to get the Sales Rep those are associated to only this account
//The Method already gets sales rep that belongs to only this account
oAccPostnBC.ExecuteQuery();
while(rAccPostn)
rAccPostn = oAccPostnBC.NextRecord();
))+.
.
Ë
After you execute the method ExecuteQuery() make sure to check if there is at least one valid
record that you desire otherwise it might result in an invalid scripting. For example in the code
above before I get the email addresses I check there is a valid record returned from my
ExecuteQuery Method using the while statement. Otherwise GetFieldValue on the BC record
will behave weird by throwing error. Also you could use IF statement to check if you expect the
result to have just one record.
) +