Create NewRecord through Siebel Business Service eScript

4.6k views Asked by At

I am trying to create a new record using BS server script.

Since the process is taking place inside the BS, the context of Parent is not present, hence I am unable to get Parent Row_Id which I need to explicitly stamp against the child record being created for visibility.

Initially I tried to pass the Parent Row_Id from applet as a profile, but this fails when there are no records in the child applet, ie this.BusComp().ParentBusComp().GetFieldValue returns "This operation is invalid when there are no records present" as the "this" context is unavailable.

Any suggestions?

2

There are 2 answers

0
Anna Joel On BEST ANSWER

I was able to achieve the desired with the below code

    sId = TheApplication().ActiveBusObject().GetBusComp("Q").ParentBusComp().GetFieldValue("Id");
    if(this.BusComp().CountRecords() > 0)
    {
        sA = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("A");
        sB = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("B");
    }
    sEntity = TheApplication().ActiveBusObject().GetBusComp("Q").Name();
2
Ranjith R On

It is for these reasons that Siebel provides Pre-Default settings at the Business Component Field level. If you wish to do this entirely through scripting, you will have to find the Active context, you have to know which BC is the parent.

Lets say you know that the Parent BC has to be Account. So

ActiveBusObject().GetBusComp("Account").GetFieldValue("Id") will give you the row id of the currently selected Account BC record. But do make sure that this script fires only in this context. So check the ActiveViewName to check this.

if(TheApplication().GetProfileAttr("ActiveViewName")=="Custom View")
{
//put the scripting here.
}