0

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?

Anna Joel
  • 107
  • 3
  • 14

2 Answers2

1

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();
Anna Joel
  • 107
  • 3
  • 14
0

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.
}
Ranjith R
  • 1,571
  • 1
  • 11
  • 11
  • Thank u Ranjith for ur response. Yes this is the approach I have taken, it works fine to get the Active BusComp Name, but still fails when var sId = ActiveBusObject().GetBusComp("Account").GetFieldValue("Id") is tried while there are no records. My assumption was the variable "sId" would be blank but instead an error is thrown that "Operation is invalid when there are no records available". Is there a mechanism that I can check if records are present without querying with Parent Row_Id. What I need is, if record is present - fetch row_id else return blank. – Anna Joel Feb 16 '16 at 06:57
  • It can be any record so the context needs to be preserved while getting corresponding Row_Id – Anna Joel Feb 16 '16 at 06:57