Showing posts with label Hiding the lookup elements if the element is assigned with records in ax 2012. Show all posts
Showing posts with label Hiding the lookup elements if the element is assigned with records in ax 2012. Show all posts

Tuesday, 8 August 2017

Hiding the lookup elements if the element is assigned with records

public void lookup()
{
  
    Query                                 query;
    QueryBuildDataSource      qbds,qbds1;
    QueryBuildRange              qbr;
    TableA                               tableA                 ;    // the table having form where we insert the lookup           values
    TableB                              tableB ;  // the table from where lookup has taken i.e "Field"
    SysTableLookup sysTableLookup =            sysTableLookup::newParameters(tableNum(tableB ),     this);

    query                         = new Query();
    qbds                          = query.addDataSource(tableNum(tableB ));
    qbds1                         =qbds.addDataSource(tableNum(TableA                 ));
    qbds1.joinMode(JoinMode::NoExistsJoin); // to negotiate the assigned elements
    qbds1.relations(true);
  
    qbr                           = qbds.addRange(fieldNum(tableB ,Field));
    sysTableLookup.parmQuery(query);
    sysTableLookup.addLookupfield(fieldNum(tableB , Field));
    sysTableLookup.performFormLookup();
}