Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to overwrite the default relation between two datasources

Posted on by

Hi, all

I want to overwrite the default relation between two datasources but not affect the other relations. Is there a way to do this?
The scenario is that:

Table InventJournalTrans has two fields: InventDimId and ToInventDimId, these two fields both has the relation with InventDim.InventDimId.

The default relation between InventJournalTrans and InventDim is InventJournalTrans.InventDimId = InventDim.InventDimId

Now, in a form, I create three datasources:
InventJournalTrans, InventDimA (inner join) and InventDimB (inner join) 

Now I want to change the relation between InventJournalTrans and InventDimB to InventJournalTrans.ToInventDimId = InventDimB.InventDimId,

but not affect other relations, especially InventJournalTrans.InventDimId = InventDimA.InventDimId.


Is there a way to overwrite the relation between InventJournalTrans and InventDimB?

I tried to clearLink(), and then addLink, but this will affect other relations.

Thank you in advance.

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: How to overwrite the default relation between two datasources

    The latest version of AX is Dynamics AX 2012 R3. I don't believe it's what you're using - the [DataSource attribute suggests that this is actually F&O and this thread belongs to another forum. Am I right?

    What about the other part of the question: ow it affected other relations? Please look at the current query string and share it with us.

    By the way, your code can be simplified a bit:

    public void init()
    {
    	super();
    
    	QueryBuildDataSource qbds = this.queryBuildDataSource();
    	qbds.clearLinks();
    	qbds.addLink(fieldNum(InventJournalTransHistory, ToInventDimId), fieldNum(InventDim, InventDimId));
    }

  • Kai Cheng Profile Picture
    Kai Cheng on at
    RE: How to overwrite the default relation between two datasources

    Now I directly write a data method to retrieve the field I need. But I am still curious how to resolve this issue.

  • Kai Cheng Profile Picture
    Kai Cheng on at
    RE: How to overwrite the default relation between two datasources

    Hi, Martin, thanks for your reply.

    The version of AX is the lastest. The code is as below:

        [DataSource]
        class InventDimReceipt
        {
            public void init()
            {
                super();
    
                QueryBuildDataSource qb;
                qb = this.query().dataSourceNo(this.name());
                qb.clearLinks();
                qb.addLink(fieldNum(InventJournalTransHistory, ToInventDimId), fieldNum(InventDim, InventDimId));
            }
    
        }

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: How to overwrite the default relation between two datasources

    Please explain how you used clearLink() and addLink() and how it affected other relations. Did you call it on InventDimB?

    Also, what is your version of AX?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans