I add 2 datasources in form , then I add this code in the init method of form
parmid = element.args().parm(); query = new Query(); queryBuildDataSource = query.addDataSource(tableNum(LoadLicenseLevel)); queryBuildDataSource.addRange(fieldnum(LoadLicenseLevel,ParentMenuItem)).value(parmid); queryBuildDataSource1 = queryBuildDataSource.addDataSource(tableNum(TreeNode)); queryBuildDataSource1.addRange(fieldnum(TreeNode,MatrixRole)).value(MatrixID.valueStr()); queryBuildDataSource1.joinMode(JoinMode::InnerJoin); queryBuildDataSource1.relations(false); queryBuildDataSource1.addLink(fieldNum(LoadLicenseLevel, EukBrowsedMenuItems), fieldNum(TreeNode, SecurableName));
But I don't get the exact values.
All right then, Next time, please make sure you compile your code and fix compilation errors.
Please show us your current code and configurations of data sources. Also, look at the actual query string and verify that you have at least one record meeting all criteria.
the name is EUKTreeNode , juste I write TreeNode ;)
I add relation between tables but I don't get any values now
Dynamics AX contains a class called TreeNode. And you're saying that you also have a table with the same name, TreeNode. It shouldn't be possible, because than the same type name would mean two different things. How could you compile and run code without knowing which of the two types you should use?
I dont understand you
If you really have two types with the same name ??
If you really have two types with the same name (which I still struggle to believe), than your environment is a funny state and getting it fixed should be your top priority.
If you don't have any relation and you want one, create it.
The table TreeNode (customized table) exists
I don't find any relations between the 2 tables
Unfortunately you still haven't describe your problem, so let me at least improve your design.
First of all, there is no TreeNode table and - as far as I can say - none can exist, because the name is already taken by TreeNode class. Can you please confirm that you have such a table? If you don't and your code won't even compile, than you should obviously fix this bug.
Also, you don't need any code to add data sources and set the type of join. You seem to already have form datasources; then simply set JoinSource and Link Type properties on the child data source.
Regarding the join relation, consider if you can't add it to child table. If you can all, you don't need addLink() either. All code you'll need is setting query ranges on the existing data sources.
Hi Martin,
I want to display informations in Grid based on 2 datasources.:
in the 1rst column I get BrowsedMenuItems from the 1rst datasource.LoadLicenseLevel
2. Based on BrowsedMenuItems I want to search these values in TreeNode datasources (Column SecurableName ).
When I get the correct informations (BrowsedMenuItems exists into TreeNode in the column SecurableName);
I want to display the securityLevel from TreeNode datasource.
in the init method I add this code that I send later.
Could you please provide a better description of your problem? "I don't get the exact values" can mean anything.
Can you also show us how you're using the query? Because your code doesn't modify form's query - it creates a new independent query. If you don't explicitly set it to the form, all your code won't have any effect. But do you really want to create a new query instead of just filtering the automatically generated query? As usual, explaining what you're trying to achieve, instead of just showing a piece code, would help us to help you.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,867 Super User 2024 Season 2
Martin Dráb 229,173 Most Valuable Professional
nmaenpaa 101,156