Hi ,
I have a view which has a metadata as a query (Screenshot below)
I want to add a data source to the existing query DirQuery in Ax 7. How do i achieve it. I have tried to use the OnInitialized event handler of the view, in a new class with the following code below but its not working.(St is the datasource , i am trying to add on the query DirQuery)
class CMCDirPartyViewQuery
{
[FormDataSourceEventHandler(formDataSourceStr(DirPartyTableRoles, DirPartyView), FormDataSourceEventType::Initialized)]
public static void DirPartyView_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
Query query;
QueryBuildDataSource qbds;
//query = sender.query();
query = new Query(queryStr(DirQuery));
qbds = query.dataSourceTable(tableNum(DirPartyView)).addDataSource('St');
qbds.clearLinks();
qbds.relations(true);
qbds.joinMode(JoinMode::InnerJoin);
qbds.fetchMode(QueryFetchMode::One2One);
qbds.addLink(fieldnum(St, Person), fieldnum(DirPartyView, Party));
qbds.addRange(fieldNum(St, Person));
}
}
Regards,
Sourav
*This post is locked for comments