Breaking

Friday, August 31, 2018

Query missing QueryBuildDataSource for FormDataSource ProdTable_IN in Dynamics Ax

Description:-

Recently I had issue regarding production order while creating from the sales order lines. I have multiple sales order lines in the sales order and for particular order line I was creating production order and I was got this issue, after struggling I found the solution and post this here so other can easily get the solution who has this issue.

You can create production orders from sales orders lines. To create a production order from a sales order

1.       Go to Accounts receivable > Common > Sales Orders > All sales orders.
2.       Select the sales order you want to create a production order for.
3.       Edit and select sales order line you want to create production order for.
4.       on the sales order lines Actions tab, choose Product and supply. In the Product and supply list select Production order.


After clicking that you will get error like below.
Error : Query missing QueryBuildDataSource for FormDataSource ProdTable IN
Solution: - Go to ProdTable form and add below code in the ProdTable DataSource LinkActive Method.
Create QueryBuildDataSource object and declare it in the method.
QueryBuildDataSource    qbdsProdTable_IN;
In the if condition add ProdTable_IN as join data source like below.
qbdsProdTable_IN = qbS.addDataSource(tableNum(ProdTable_IN));
qbdsProdTable_IN.name(ProdTable_IN_ds.name());
qbdsProdTable_IN.addLink(fieldNum(ProdTable, RecId), fieldNum(ProdTable_IN, ProdTable));
qbdsProdTable_IN.joinMode(JoinMode::InnerJoin);
like below i have create join ProdTable_IN with ProdTable for which i was getting errors.
if (element.args() && element.args().caller())
{
   if (element.args().dataset() == tableNum(SalesLine))
   {
      prodTableReferences = new ProdTableReferences();
      prodTableReferences.initfromSalesLine(element.args().record());
      
      query = new Query();
      qbS   = query.addDataSource(tableNum(ProdTable));
      qbS.name(prodTable_ds.name());
      
      qbsDim = qbS.addDataSource(tableNum(InventDim));
      qbsDim.name(inventDim_DS.name());
      qbsDim.addLink(fieldNum(ProdTable,InventDimId),fieldNum(InventDim,InventDimId));
      qbsDim.joinMode(JoinMode::InnerJoin);
      //Create new join
      qbdsProdTable_IN = qbS.addDataSource(tableNum(ProdTable_IN));
      qbdsProdTable_IN.name(ProdTable_IN_ds.name());
      qbdsProdTable_IN.addLink(fieldNum(ProdTable, RecId), fieldNum(ProdTable_IN, ProdTable));
      qbdsProdTable_IN.joinMode(JoinMode::InnerJoin);
      
      prodTableReferences.addQueryRanges(query);
      
      prodTable_ds.query(query);
   }
}
Now create production order from sales order line and you will success to create production order.

No comments:

Post a Comment

Thanks for your comment.