Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

How to add a data source to an existing query in ax 7

$
0
0

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


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>