I am new to X++ and trying to build a new form which shows related data of customer, including the primary address info of the customer.
In the new form, I added 3 data sources and defined their properties as follows:
1. CustTable; Join Source: blank; Link Type: blank
2. DirPartyTable; Join Source: CustTable; Link Type: Inner Join
3. LogisticsPostalAddress; Join Source: DirPartyTable; Link Type: Outer Join
I override these data sources's init() to define the relationship between them
[DataSource]
class DirPartyTable
{
public void init()
{
super();
QueryBuildDataSource qbdsCustTable,qbdsDirPartyTable;
qbdsCustTable = CustTable_ds.query().dataSourceTable(tableNum(CustTable));
qbdsDirPartyTable = qbdsCustTable.addDataSource(tableNum(DirPartyTable));
qbdsDirPartyTable.addLink(fieldNum(CustTable, Party), fieldNum(DirPartyTable, RecId));
qbdsDirPartyTable.joinMode(JoinMode::InnerJoin);
}
}
[DataSource]
class LogisticsPostalAddress
{
public void init()
{
super();
QueryBuildDataSource qbdsDirPartyTable,qbdsLogisticsPostalAddress;
qbdsDirPartyTable = DirPartyTable_ds.query().dataSourceTable(tableNum(DirPartyTable));
qbdsLogisticsPostalAddress = qbdsDirPartyTable.addDataSource(tableNum(LogisticsPostalAddress));
qbdsLogisticsPostalAddress.addLink(fieldNum(DirPartyTable, PrimaryAddressLocation),fieldNum(LogisticsPostalAddress, Location));
qbdsLogisticsPostalAddress.joinMode(JoinMode::OuterJoin);
}
}
Then I put the fields of DirPartyTable and LogisticsPostalAddress to the form. When I opened the form, I can see the value of DirPartyTable fields but the address fields are blank. Could someone tell me where was wrong?