I was modifying a Siebel Business Service few days ago when I faced this problem. It took me almost 1 hr to resolve the issue and then it turned out to be issue of duplicate declaration. Here is what happened.
The BS already had a code that was something like
var BO = TheApplication().GetBusObject(“Contact”);
var BC = BO.GetBusComp(“Contact”)
var BC1 = BO.GetBusComp(“Account”);
//complete logic of 15 lines was below this
I had to add my code below this. Here is how the BS looked after I added my code
var BO = TheApplication().GetBusObject(“Contact”);
var BC = BO.GetBusComp(“Contact”)
//complete logic of 15 lines was below this
if (BC.GetFieldValue (“Status”) == “Pending”)
{
//My Logic of 15 lines here
if (value == “IntheLoop”)
{
var BO = TheApplication().GetBusObject(“Opportunity”);
var BC = BO.GetBusComp(“Opportunity”);
//My complete logic of 10 lines
BC1.SetFieldValue (“Status”,”Done”);
return (CancelOperation);
}
}
If you read the code carefully you will realize that I had declared the variables BC and BO twice. This was a very small mistake but it costed me 1 hr of my effort. This code didn’t return any error, it just didn’t do anything. The value for that field was not set.
When I tried to do a use GetFieldValue I got “undefined” as value. I just couldn’t figure out the reason for this error. Then I had to test it by doing RaiseErrorText Line by Line until I reached the Line
var BO = TheApplication().GetBusObject(“Contact”);
Here I realized that I had declared variable BO and BC two times and the problem was because of that only. So changing the code to
var BO1 = TheApplication().GetBusObject(“Opportunity”);
var BC1 = BO1.GetBusComp(“Opportunity”);
Solved the problem.

(1 votes, average: 4 out of 5)
2 Comments at "Variable Declaration – Problem and Solution"
Hi Neel,
You can also debug the script by using debug mode and F8 key.
Also always whenever my script doesnt work properly I used to find all the varibles used and where they are used using Ctrl+F command
this method can give you idea if you do any mistake in declaring or using variables.
Well Piyush,
That would have been the first thing I would have done if it was tools side BS but unfortunately I was working on client side BS
so didn’t had that option.
Comment Now!