Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

Posted on by 305

Hello All,

I use jumpref() to make AX Data auto link to Ax Transaction Form.

Form InventSum inside Grid Field data ,when user click the data(number),

Ax will auto open the InventTrans form (by ItemId).

I use jumpref, but can't work.

I don't know how to get the record between the InventTans Table and InventSum Table.

Please help and Thanks.

==========================

My problem is:

below is my code that compile is OK.

but when in running (use mouse that right click the view detail function) get the error message:

Could not process the lookupRecord value on the Args instance. The table 'InventTrans' does not exist as a root FormDataSource for the form 'InventTrans'.

==========================>My code

public void jumpRef()

{

   //super();

   Args                        locArgs = new Args();

//*    DirPartyTable               locDirPartyTable;

   InventTrans                 inventTrans;

   locArgs.caller(this);

   // Find and set buffe ------ I don't know how to do this!!

inventTrans = InventTrans:: find (InventSum.ItemId);   // InventTrans no find ItemId method??

//*  locDirPartyTable = DirPartyTable::findRec(CustTable::find(SalesTable.CustAccount).Party);

   inventTrans.ItemId  =  InventSum.ItemId;

   // Set record

//* locArgs.record(locDirPartyTable);

   locArgs.record(inventTrans);

   locArgs.lookupRecord(inventTrans);

   new MenuFunction(menuitemDisplayStr(InventTransItemIdx), MenuItemType::Display).run(locArgs);

}

*This post is locked for comments

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    That's strange, I get a bit different error:

    Could not process the lookupRecord value on the Args instance. The table 'InventTable' does not exist as a root FormDataSource for the form 'InventTrans'.


    Anyway, seems we need a bit different solution.

    First of all, please remove the row with "locArgs.lookupRecord(inventTable);"

    Then go to the init method of InventTrans form, and add this logic after the super() call (I suggest you create a new method and call it from the init method):

        QueryBuildDataSource qbds;
        InventTable inventTable;
        
        if (element.args().record() && element.args().record().TableId == tableNum(InventTable))
        {
            inventTable = element.args().record();
            qbds = inventTrans_ds.query().dataSourceTable(tableNum(InventTrans)); 
            qbds.addRange(fieldNum(InventTrans, ItemId)).value(inventTable.ItemId);
        }
  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    Hello Nikolaos,

    Had get the error, please help and thanks.

    The Error Message:

    Could not process the lookupRecord value on the Args instance. The table 'InventTrans' does not exist as a root FormDataSource for the form 'InventTrans'.

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    Hello  Nikolaos,

    I paste your code in AX and get a error message: please help and thank you.

    The Error Message:

    Could not process the lookupRecord value on the Args instance. The table 'InventTrans' does not exist as a root FormDataSource for the form 'InventTrans'.

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    Hello Martin,

    This case that I need to perform that when user direct click the on hand qty field,

    then AX  like a hyperlink to direct open about this Itemid's on-hand transaction.

    so why use jumpRef(), not add a menu button and transaction menu button is have in AX  default UI.

    but I still can't perform the hyperlink, need use right click the mouse and use view detail.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    First of all, let me format your code so it's easier to read. Next time, please clean it up before sharing and use the </> button in the rich formatting view to paste source code.

    public void jumpRef()
    {
        Args locArgs = new Args();
        InventTrans inventTrans;
    
        locArgs.caller(this);
    
        // Find and set buffe ------ I don't know how to do this!!
        inventTrans = InventTrans::find(InventSum.ItemId); // InventTrans no find ItemId method??
    
        inventTrans.ItemId  =  InventSum.ItemId;
    
        locArgs.record(inventTrans);
        locArgs.lookupRecord(inventTrans);
    
        new MenuFunction(menuitemDisplayStr(InventTransItemIdx), MenuItemType::Display).run(locArgs);
    }

    If you want to see all inventory transactions for a given item, trying to find a single inventory transaction and passing it as a parameter doesn't match your requirements. You don't want to display a single transaction.

    Also, why do you use jumpRef() in the first place? Such things can be usually done without code, just by using a menu item button. Look at InventTransItemIdx button in InventIOnHandItem form; it does the same thing you're trying to achieve.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: jumpref() how to find record about InventTrans::find(InventSum.ItemId)??

    Yes, you are right that InventTrans has no find method for ItemId. This is because ItemId is not unique in InventTrans. So it's not possible to find one InventTrans record by using an ItemId.

    I would put an inventTable in the args since that's unique for every item id. And every other table that has ItemId field has a relation to inventTable.

    Also there is no menu item called "InventTransItemIdx", instead it's called "InventTrans".

    So it would be something like this:

    public void jumpRef()
    {
       InventTable inventTable = InventTable::find(inventSum.ItemId);
       Args                        locArgs = new Args();
    
       locArgs.caller(this);
       locArgs.record(inventTable);
       locArgs.lookupRecord(inventTable);
       new MenuFunction(menuitemDisplayStr(InventTrans), MenuItemType::Display).run(locArgs);
    }

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans