Child table in Application Designer

This article is obsolete. Please refer to this one.

If you are a creating custom objects and applications in TPAE you may need at some point to create a child table like the Subassemblies in the Assets application.


Let's pretend we have a parent table called TB1 and a child table called TB2.
The fundamental concept is to have a field in the child table that points to a specific row in the parent table. In our example such field is TB2.TB1ID.

In order to have the child table to behave correctly is to 'link' in some way the child rows to the parent object. If not doing this the child records will disappear as soon as you save the record.

Basic method using Database Configuration and Application Designer

First of all you need a relationship from the TB1 table to the TB2 records. In Database Configuration define the following relationship in object TB1:
In the Application Designer you have to use this relationship in the child table.
The last important step is to initialize the TB2.TB1ID field on child records. To achieve this, add a Default Value control with the following configuration:
This will set the 'link' between parent and child tables.

Alternative method using Java

An alternative method is to initialize this link in the child Mbo using Java. Here is how the child Mbo class should look like.

public class Tb2Mbo extends Mbo implements MboRemote
{
  public Tb2Mbo(MboSet ms) throws MXException, RemoteException
  {
    super(ms);
  }

  public void add() throws MXException, RemoteException
  {
    super.add();

    MboRemote ownerMbo = getOwner();
    if(ownerMbo != null)
    {
      String tb1id = ownerMbo.getString("tb1id");
      setValue("tb1id", tb1id, NOACCESSCHECK|NOVALIDATION_AND_NOACTION);
    }
  }
}

Labels: , ,