This article discusses Siebel Scripting Best Practices.
Siebel Scripting best practices in developing applications with Siebel Tools.
Siebel Scripting is used to accomplish some functionality which cannot be achieved by general Siebel Configuration. However, Scripting is one of the main reasons for giving rise to performance problems in Siebel Applications. If you need to write code write a Business Service to increase modularity.1. Try to avoid multiple queries within the code if only one query can be used.
I am providing below a simple example, the following code will get the email address of the contact on a Opportunity:
var boOpty;However, there is no need to query on Contact Business Component separately because there already exists a join to the Contact Email field:
var bcOpty;
var boCon;
var bcCon;
var sConEmail = "";
try
{
boOpty = TheApplication().GetBusObject("Opportunity");
bcOpty = boOpty.GetBusComp("Opportunity");
boCon = TheApplication().GetBusObject("Contact");
bcCon = boCon.GetBusComp("Contact");
with (bcOpty)
{
ActivateField("Opportunity Number");
ActivateField("Contact Id");
ClearToQuery();
SetSearchSpec("Opportunity Number","abc123");
ExecuteQuery(ForwardOnly);
if (FirstRecord())
{
bcCon.ActivateField("Email Address");
bcCon.ClearToQuery();
bcCon.SetSearchSpec("Id", GetFieldValue("Contact Id"));
bcCon.ExecuteQuery(ForwardOnly);
if (bcCon.FirstRecord())
{
sConEmail = bcCon.GetFieldValue("Email Address");
}
}
}
}
catch(e)
{TheApplication().RaiseErrorText(e.toString());
}
finally
{
bcCon = null;
boCon = null;
bcOpty = null;
boOpty = null;
}
var boOpty;
var bcOpty;
var sConEmail = "";
try {
boSR = TheApplication().GetBusObject("Opportunity");
bcSR = boSR.GetBusComp("Opportunity");
with (bcSR)
{
ActivateField("Opportunity Number");
ActivateField("Contact Email");
ClearToQuery();
SetSearchSpec("Opportunity Number","abc123");
ExecuteQuery(ForwardOnly);
if (FirstRecord())
{
sConEmail = bcCon.GetFieldValue("Contact Address");
}
}
}
catch(e)
{
TheApplication().RaiseErrorText(e.toString());
}
finally{
bcOpty = null;
boOpty = null;
}
For instance, lets say that you set a profile attribute on the BusComp_NewRecord event script to flag that a Contact record has been created:
TheApplication().SetProfileAttr("NEW_CONTACT","Y");
To be completely sure the reset of the profile attribute can be placed in the finally block, this will guarantee reset whenever the BusComp_WriteRecord event code is executed.
3. Please make sure that while loops with delete record do not include NextRecord. If you use ExecuteQuery and then need to scroll through each record in the result set you would use logic such as this:
However, if you were to perform a DeleteRecord in the processing within the while loop you would not want to use NextRecord to go to the next record, because DeleteRecord will automatically place the cursor on the next record, if you used NextRecord it would skip the current record. Therefore the code should look like as cited below.
try {
if (TheApplication().GetProfileAttr("NEW_CONTACT") == "Y")
{
TheApplication().SetProfileAttr("NEW_CONTACT","");
//...then continue processing}
//....}
catch(e)
{
TheApplication().RaiseErrorText(e.toString());
}
finally{
TheApplication().SetProfileAttr("NEW_CONTACT","");
}
ExecuteQuery(ForwardOnly)
isRecord = FirstRecord();
while (isRecord)
{
//...do your processingisRecord = NextRecord();
}
ExecuteQuery(ForwardOnly)
isRecord = FirstRecord();
while (isRecord)
{
isRecord = DeleteRecord();
//do not use: isRecord = NextRecord();}
Related Posts
No comments :