Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

how to Join 2 tables in form ?

(0) ShareShare
ReportReport
Posted on by 570

hello.. 

i added a new dataSource in PurchLineOpenOrder Form

so , i want to create a new relation from PurchLine to EcoResProduct 

in init() method i added next lines , maybe the code is wrong !!

void init()
{
    QueryBuildDataSource    purchLineQbds,ecoResProductQbds;
    Query   query = new Query();
    
     purchLineQbds = query.dataSourceTable(tableNum(PurchLine));
     ecoResProductQbds = purchLineQbds.addDataSource(tableNum(EcoResProduct)); //line 7  
     ecoResProductQbds.joinMode(JoinMode::InnerJoin);
     ecoResProductQbds.relations(false);
     ecoResProductQbds.addLink(fieldNum(PurchLine, ItemId), fieldNum(EcoResProduct, DisplayProductNumber));    
    super();


but when form run the next error displayed

QueryBuildDataSource object not initialized.

Stack trace

(C)\Forms\PurchLineOpenOrder\Methods\init - line 7
(C)\Classes\SysSetupFormRun\init - line 3

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to Join 2 tables in form ?

    Hi Ismail,

    If any of above answers resolved your issue, could please be so kind and mark them as verified to help other forum members with similar issues.

    Kind Regards,

    V

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to Join 2 tables in form ?

    Hi Ismail,

    open the properties tab for the field you added StringEdit:PurchLine_Name and change its height to 15 it will shrink it down back to normal.

    Kind Regards,

    v

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: how to Join 2 tables in form ?

    Can you explain why form look changed after add name field ?

    New look

    2604.form.png

    Old

    2604.form.png

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to Join 2 tables in form ?

    Hi Ismail,

    If you are trying to add item name within the form, simply drag "name" field from PurchLine DS to form Design/PurchLine grid and it should display all necessary item names.

    Kind Regards,

    V

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: how to Join 2 tables in form ?

    i'll test it tonight , and give you the result
    Thank you

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: how to Join 2 tables in form ?

    OK, if that is the case, you can set joinsource on EcoResProduct to InventTable, and joinmode Innerjoin. No Code required.

    Inventtable is already joined to PurchLine. As simple as that.

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: how to Join 2 tables in form ?

    Just i need to search by item name , so i don't need to use display method

    thanks

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: how to Join 2 tables in form ?

    May I ask, why do you want to connect to EcoResPRoduct from PurchLine? If item Name is all that you are looking for, there are better Options..

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: how to Join 2 tables in form ?
    public void init()
    {
    
         QueryBuildDataSource    purchLineQbds,ecoResProductQbds;
    
        super();
    
         ecoResProductQbds = this.query().dataSourceTable(tableNum(EcoResProduct));
         purchLineQbds= ecoResProductQbds.addDataSource(tableNum(Purchline));
         purchLineQbds.joinMode(JoinMode::InnerJoin);
         purchLineQbds.relations(false);
         purchLineQbds.addLink(fieldNum(EcoResProduct, DisplayProductNumber),fieldNum(PurchLine, ItemId));
    }

    No error but the relation not working fine , wrong names for all items

    Thanks

  • Crispin John Augustine Profile Picture
    Crispin John Augustine 37,081 on at
    RE: how to Join 2 tables in form ?

    try in the EcoResProduct datasource init().

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans