Few days ago a user on siebelunleashed forum asked me a question. It appeared to be a simple question to be me but can be difficult to answer by a newbie in Siebel. So, I thought I would answer it in complete detail through a post. The question was related to below given requirement.
Requirement:
When a new record for Opportunity is created then an Activity needs to be created which should have certain details of the newly created opportunity and the activity should also be related to this opportunity.
User had also posted the code which he had written to achieve this requirement. The problem he faced was that the opportunity created with this code as was not related to the opportunity. So, somebody helped him to modify the code and include an additional statement which was:
bc.SetFieldValue(”Oppty Id”,OptyId );
This helped in establishing the relationship of this activity with the newly created opportunity.
The question or doubt which he had was:
“How do u determine which field values you have to use? e.g. here we have used OptyId - how do we determine this?”
The answer to the above question is:
In Siebel parent/child relationships are created with the help of link. In link definition we provide Source BC, Destination BC, Source Field and Destination Field.
The Field which is mentioned in Destination Field stores the Row Id of parent record and link uses this field to pull up all the child records for a particular parent. So whenever you need to create parent/child relationship through scripting you will need to populate this field with appropriate Id.
To determine which field to use in such cases here are the steps you need to follow
- Go To the Business Object in Tools
- Query for the BO that you will use.
- In BO query for the Child BC (Action in the above example)
- Click on the link specified in the Link Field (it will take you the link object)
- Copy the value in the Destination Field that is the field that you need to use in your scripting.
This Field should always contain the Row Id of parent record otherwise it will be Standalone or an Orphan record.


(6 votes, average: 3.67 out of 5)
3 Comments at "Basic siebel scripting question"
So in this case, do you need an intersection table to relate multiple activities to an oppty? Thanks for the help.
Hi,
imho this is not really a scripting requirement.
If you create a workflow on the Opportunity BO and use a Siebel Operation step to create the activity, it will be automatically linked to the Oppty.
Let us always remember:
The best script you’ll ever write is the script you never write.
@lex
Hi,
In this script why we have to explicitly need to set the ID? Basically whenever a chld BC is required we can use following code if its ok to use UI context.
var oActiveBusObject = TheApplication().ActiveBusObject();
var oActionBC = oActiveBusObject.GetBusComp(”Action”);
oActionBC.NewRecord(NewAfter);
This will also help in maintaining all the relationships that Siebel maintains whenever a child BC record is entered instead explicitly setting the IDs.
Comment Now!