web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

datasource join giving duplicate values

(0) ShareShare
ReportReport
Posted on by

Hello experts,

I am having duplicated records while adding two datasource of the table Dirpartycontactview on CustTable form, my aim is to have two string control added on a grid that will display the telephone and email of each client, these two values are both contained in the locator field, so for both datasources i have set the join source property to CustTable and the link type to Outer-join, i used the OnInitialized event handler of each datasource to add the ranges etc, the result is that i have like 20 of the same record or even more, if i remove one datasource it will work fine but then i won't be able to reference my second string control, somehow using these two datasource is messing things up. can you please show me what i am missing?

this one for the telephone field

[FormDataSourceEventHandler(formDataSourceStr(CustTable, DirPartyContactInfoViewTelephone), FormDataSourceEventType::Initialized)]
public static void DirPartyContactInfoViewTelephone_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
//FormRun formRun = sender.formRun() as FormRun;
FormDataSource DirPartyContactInfoViewTelephone_ds = sender;

Query q= DirPartyContactInfoViewTelephone_ds.query();

QueryBuildDataSource qbds = q.dataSourceTable(tableNum(DirPartyContactInfoView));

qbds.addLink(fieldNum(CustTable, party), fieldNum(DirPartyContactInfoView,Party));
QueryBuildRange qbr1 = qbds.addRange(fieldNum(DirPartyContactInfoView, Type));
qbr1.value(queryValue(LogisticsElectronicAddressMethodType::Phone));
QueryBuildRange qbr2 = qbds.addRange(fieldNum(DirPartyContactInfoView, IsPrimary ));
qbr2.value(queryValue(NoYes::Yes));
}


and this one for the address

[FormDataSourceEventHandler(formDataSourceStr(CustTable, DirPartyContactInfoViewTelephone), FormDataSourceEventType::Initialized)]
public static void DirPartyContactInfoViewTelephone_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
//FormRun formRun = sender.formRun() as FormRun;
FormDataSource DirPartyContactInfoViewTelephone_ds = sender;

Query q= DirPartyContactInfoViewTelephone_ds.query();

QueryBuildDataSource qbds = q.dataSourceTable(tableNum(DirPartyContactInfoView));

qbds.addLink(fieldNum(CustTable, party), fieldNum(DirPartyContactInfoView,Party));
QueryBuildRange qbr1 = qbds.addRange(fieldNum(DirPartyContactInfoView, Type));
qbr1.value(queryValue(LogisticsElectronicAddressMethodType::Phone));
QueryBuildRange qbr2 = qbds.addRange(fieldNum(DirPartyContactInfoView, IsPrimary ));
qbr2.value(queryValue(NoYes::Yes));
}


*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    is the relation, you can have more than one party, add the electronicAddress to that query relation.

    6747.duplicate.png

  • Mea_ Profile Picture
    60,284 on at

    Hi AXNinja2506,

    Are you sure that there is only one record with this type for each customer ? You can simple check this writing select in a job.

    If you have few you can try to set "FirstOnly" property on DS or use display method instead.

  • Community Member Profile Picture
    on at

    Thank you, the problem was that i was using q.datasourcetable instead of q.datasource(formdatasourcestr());

    so it was refering to the table instead of the datasource

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans