Reputation: 3
I want to add a custom relation to datasource into a form in AX 2012.
When i use the option to add datasource as Referenced Datasource the system makes a automatic join with AutoReport field into field group into the table, but i want to get information using another field for join
Example.
I have CustTrans Table and i want the order account name, but when i put the reference datasource only appears the account name and not the order account name.
I don't know if the option with querybuilddatasource works.
Thanks for your time
Upvotes: 0
Views: 2342
Reputation: 6793
You can create a display method on the CustTrans
table instead of joining a new data source, e.g.:
//BP Deviation Documented
display CustName orderAccountName()
{
CustTable custTable;
DirPartyTable partyTable;
select firstonly Party from custTable
where custTable.AccountNum == this.OrderAccount
join Name from partyTable
where partyTable.RecId == custTable.Party;
return partyTable.Name;
}
Then you can just use this display method to show to order account name on the form.
If you do want to add a new data source and link it using the OrderAccount
field, you can add the CustTable
data source as usual (JoinSource = CustTrans, LinkType = InnerJoin or OuterJoin, etc.) and override its init
method, e.g.:
void init()
{
QueryBuildDataSource qbds;
super();
qbds = this.queryBuildDataSource();
qbds.clearLinks();
qbds.addLink(fieldNum(CustTrans, OrderAccount), fieldNum(CustTable, AccountNum));
}
Upvotes: 2