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)

based on arguments how we can show data in another form

(0) ShareShare
ReportReport
Posted on by 327

Hi all i have form show below

2134.Untitled.png

the product number  is coming from ecoresproduct table.

i have a requirement if i select one product number and if i press show details button it should open a new form.

assume that product number having two transaction it is pricedisc table.if i click show details button it should show those 2 transaction in a new form how can i achieve it.

thanks in advance....

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    There are two main ways how to achieve it:

    1) If you have relation between tables, a dynalink is constructed automatically and you'll get this behavior without even a single line of code.

    2) If it's not possible (which will be your case here), you have to add some code. In the target form, you can access arguments by calling this.args(). The Args object you get contains several things; what you're interested in is record(). When you have the record, you can do anything you like with it, such as adding corresponding query ranges.

    Note that it assumes that you're using a menu item button. Also, you must set the DataSource property if you're getting records from a wrong datasource.

  • karthik143 Profile Picture
    327 on at

    thanks for replay Mr.martin

    there is no relation between those tow tables

    inside button i have written clicked method

    void clicked()

    {

    Args args;

    FormRun formRun;

    ;

    super();

    args = new args(formstr(LatestSalesPrice)); // sending Args(record) to FormB

    args.record(EcoResProduct);

    //args.record(InventTable);

    formrun = classfactory.formrunclass(args);

    formrun.init();

    formrun.run();

    formrun.wait();

    formrun.detach();

    }

    in button i am calling my form menas second form there init method i have written some code

    Query         query;

     QueryBuildRange qbr;

     EcoResProduct   _EcoResProduct;

     PriceDiscTable  _PriceDiscTable;

     Str           _recid;

       super();

      _EcoResProduct = element.args().record();

      _recid= element.args().parm();

      query= new Query();

      qbr=query.addDataSource(tableNum(PriceDiscTable)).addRange(fieldNum(PriceDiscTable,ItemRelation));

      qbr.value(_recid);

       PriceDiscTable_ds.query(query);

       super();

    }

    but this is not working can you please look this once

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    "is not working" isn't ever a good description of any problem. Please give us more information.

    One obvious bug is that you're trying to create a range based on element.args().parm(), which will always be empty, as you never set any value there. It would be completely obvious if you tried to debug your code. Please learn how to use the debugger; it an absolutely crucial tool for debugging.

    Another bug is that your code is at a wrong place. You set a query, but it's then overwritten by the standard query generated from the form definition. Do it after super(), possibly in init() of the datasource.

    Also, don't create a completely new query. Let AX to initialize the query and then merely add the query range to it. You'll get the query datasource by calling PriceDiscTable_ds.queryBuildDataSource() (assuming that you have a datasource named PriceDiscTable).

  • karthik143 Profile Picture
    327 on at

    hi martin please look into bellow code

    Query                      query;

     QueryBuildDataSource       qbds,qbds1;

     QueryBuildRange            qbr,qbr1;

     EcoResProduct             _EcoResProduct;

     PriceDiscTable           _PriceDiscTable;

     Str                      _recid;

     super();

      _EcoResProduct = element.args().record();

      _recid= element.args().parm();

      query= new Query();

       qbds=query.addDataSource(tableNum(PriceDiscTable));

       qbr=qbds.addRange(fieldNum(PriceDiscTable,ItemRelation));

       qbr.value(queryValue(_EcoResProduct.productNumber()));

       qbds1=qbds.addDataSource(tableNum(InventDim));

       qbds1.joinMode(JoinMode::InnerJoin);

       qbds1.relations(true);

       PriceDiscTable_ds.query(query);

    from this code i can able to get data form pricedisc table...but i am not able to get data from inventdim table....is my query is correct?

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Well, I expected you to actually use the value from record(), not passing RecId (int64) through parm() (string). Although it's possible, it's not the usual approach.

    I see you ignore my advice about using the query instead of replacing it with a new one. Why? You had to write more code to create a worse solution.

    I have no information about your InventDim datasource and how it's related to what we've discussed so far. It seems to be a different topic.

    By the way, when pasting code, please switch to the rich formatting and use </> button. The result will be more readable and easier to copy and run.

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