SetQuery to DataSource subsequently

I have two dataSources: articleColoursDs (filtered by article) and ColourDs.
Entity: SalesOrderLine, ArticleColour


for (SalesOrderLine soLine : orderLinesDs.getItems()) {        
                articleColoursDs.setQuery("select e from demodb$ArticleColour e where e.article.id = :soLine.article.id");
                articleColoursDs.refresh();
                ..........

The above doesn’t work where my underlying question is, how can i reference the article from the “soLine” above in setQuery?

Hello,
It is hard to understand the intention.
But it seems, that the code below should work in that case.


for (SalesOrderLine soLine : orderLinesDs.getItems()) {        
   articleColoursDs.setQuery("select e from demodb$ArticleColour e where e.article.id = :custom$soLine_article_id");
   articleColoursDs.refresh(ParamsMap.of("soLine_article_id", soLine.getArticle()));
.................................

Look https://doc.cuba-platform.com/manual-6.1/datasource_query_params.html for information on query parameters.

Maybe, the better way is to use “Nested datasource” for the ArticleColour entity.