当前位置: 动力学知识库 > 问答 > 编程问答 >

Create NewRecord through Siebel Business Service eScript

问题描述:

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?

网友答案:

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.
}
网友答案:

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();
分享给朋友:
您可能感兴趣的文章:
随机阅读: