Announcements
Hello everybody,
I've been trying for weeks to adding my view in AOT (ANW_GRUvwInventSum) with the SalesLine table. The challenge here is, that I had to have included the VIEW as a DataSource in the form. I've included the code so maybe you can understand, what I'm talking about. I am currently getting the error message that the DataSource object cannot be initialized. Does anyone have a solution for this? Many thanks in advance
public void init() { QueryBuildDataSource oQBDS1, oQBDS2; Query oQuery = new Query(); ; oQBDS1 = oQuery.dataSourceName("dsANW_GRUvwInventSum"); oQBDS2 = oQBDS1.addDataSource(tableNum(ANW_GRUvwInventSum)); oQBDS2.joinMode(JoinMode::InnerJoin); oQBDS2.relations(false); oQBDS2.addLink(fieldNum(SalesLine, ItemId), fieldNum(ANW_GRUvwInventSum, ItemId)); super(); }
Don't worry about tags, I'll fix them.
Thank you for the quick help. It doesn't look as complicated as my code. I'll try it out. I'm getting one more: syntax error
.at the moment,
To your question:
By the way, why did you attach tags "Connector for CRM", "Install and Upgrade" and "Reporting and BI"?
That was my first post and after I posted my question, I saw that the TAGS belong to my question. : D
Yes, that's not correct.
Thank You
Thank you for the great help.
Even if your code worked, it wouldn't have any effect. I think you want to modify the query used by the form, but that's not what you're doing. You create a completely new query, which isn't used anywhere and it'll cease to exist at the end of init() method. You also try to find dsANW_GRUvwInventSum data source in your empty query, which must fail.
What you need to do is taking the actual form query. You can throw away addDataSource(), because you've already added the data source to the form. You also don't need setting InnerJoin in code - you can do it in data source properties. And relations(false) doesn't seem to be useful either - I think you want to add a link exactly because you can't use relations.
Therefore all you need is something like this:
public void init() { super(); // Let the system initialize the data source before you try to change it this.queryBuildDataSource().addLink(fieldNum(SalesLine, ItemId), fieldNum(ANW_GRUvwInventSum, ItemId)); }
By the way, why did you attach tags "Connector for CRM", "Install and Upgrade" and "Reporting and BI"?
First of all, could you just specify Join data source and Join mode in the properties of this new data source? This way you would not need to develop anything.
If that doesn't work, and you need to define the link in code, then I think your code needs some enhancement. You should join this new data source to SalesLine data source. So one of your QueryBuildDataSource instances should point to SalesLine data source, and one of them should point to your new data source. Then you can link them.
Additionally, if you might need to put your code after the super() call of the init method of the data source.
André Arnaud de Cal...
294,165
Super User 2025 Season 1
Martin Dráb
232,964
Most Valuable Professional
nmaenpaa
101,158
Moderator