I need to know about the differences between Link and Dynalink.
Need a simple example of:
Link in code two tables, and ignore the default link between them.
i.e SalesTable + SalesLine ...
Connect them by some other column (or columns).
Below an example. Feel free to change the link. The infolog will show the xml representation of the query, which I've found to be helpful in debugging sometimes.
query = new Query();
// Add SalesTable main datasource
datasource = query.addDataSource(tableNum(SalesTable));
// Add child datasource "SalesLine" to previously created DS
datasource = datasource.addDataSource(tableNum(SalesLine));
// Indicate you don't want to use relations automatically
// Add link between parent field and child field
datasource.addLink(fieldNum(SalesTable, SalesId), fieldNum(SalesLine, SalesId));
A link creates a join (inner by default) between two QueryBuildDatasources of the same query. Data from the corresponding tables is fetched simultaneously, in a single query to the database. A dynalink creates additional where clauses on a data source, and its data is fetched in a subquery - separately from the dynalinked data source. Dynalinks are a great feature of Dynamics AX that allows data in different forms to be "synchronized" while you navigate through data on one form.
The function addDynalink takes 3 arguments.
The second argument is "common _DynamicFile" - What is it for?
Dynalink will update a query based on a "live" table buffer. This is used between forms, as gl00mie explained, so if you have two forms open one form will update it's query if you select a different record on the other. This is achieved by adding a dynalink on a specific field, and passing in the record (common) to trigger from. I don't see this being useful in a regular query object, although I must assume it works (I never tried).
You can see this process in action for example if you go to inventory management > item details and click on "transactions". Leave the transactions form open but select a different item in your item details screen. AX automatically does dynalinking a lot on forms, based on the args.record() being passed along.
In form: custPackingSlipJournal, dataSource: custPackingSlipJour, method: init, there is a code behind.
I want to understand that code ... and can I do the Dynalink otherwise (I want to do the same, but limit it to a specific item).
Business Applications communities