Axapta V/s Me

Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets the technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks.

Multiple Tables in field Lookup method

How To use Multiple Tables in Form LookUp

public void lookup()
{
  Query                   query = new Query();
  QueryBuildDataSource    qbdsPurchTable,QbdsInvntQO, qbdsInventDim;
  QueryBuildRange         qbrVendId,qbrPurchStatus,qbrPurchType;
  QueryBuildLink          qblink1, QbLink2;

  SysTableLookup  sysTableLookup = sysTableLookup::newParameters(tableNum(PurchTable), this);
  ;//breakpoint;
  qbdsPurchTable = query.addDataSource(tableNum(PurchTable));

  QbdsInvntQO = qbdsPurchTable.addDataSource(tableNum(InventQuarantineOrder));
  QbdsInvntQO.relations(false);
  QbdsInvntQO.joinMode(JoinMode::NoExistsJoin);
  qblink1 =  QbdsInvntQO.addLink(FieldNum(PurchTable,PurchId),FieldNum(InventQuarantineOrder,TransRefId));

  qbdsInventDim = QbdsInvntQO.addDataSource(tableNum(InventDim));
  qbdsInventDim.relations(false);
  qbdsInventDim.joinMode(JoinMode::NoExistsJoin);
  QbLink2 = qbdsInventDim.addLink(FieldNum(InventQuarantineOrder,InventDimId),FieldNum(InventDim,InventDimId));

  qbdsPurchTable.addRange(fieldNum(PurchTable, OrderAccount)).value(PurchTable_InvoiceAccountGrid.valueStr());
  qbdsPurchTable.addRange(FieldNum(PurchTable, PurchStatus)).value("Invoiced,Received");
  QbdsInvntQO.addRange(fieldNum(InventQuarantineOrder, Status)).value(queryValue(InventQuarantineStatus::Ended));
  qbdsInventDim.addRange(fieldNum(InventDim, InventLocationId)).value("102018");

  sysTableLookup.addLookupfield(fieldNum(PurchTable,OrderAccount));
  sysTableLookup.addLookupfield(fieldNum(PurchTable,PurchId),true);
  sysTableLookup.addLookupfield(fieldNum(PurchTable,PurchStatus));

  sysTableLookup.parmQuery(query);
  sysTableLookup.performFormLookup();
}

-Harry

2 comments:

  1. hi., this is really helpful to me, thanks

    ReplyDelete
  2. Its is a prefect example for what you want from a single table but if you want to show field from multiple tables you can do it. for example please refer to: https://360dynamics.blogspot.com/2017/10/multi-table-lookup-display-fields-from.html

    ReplyDelete

Thanks

Note: Only a member of this blog may post a comment.