Showing posts with label Reference Lookup for Customer Delivery Address. Show all posts
Showing posts with label Reference Lookup for Customer Delivery Address. Show all posts

Monday, 11 July 2016

Reference Lookup for Customer Delivery Address


















  • Create a Table with fields CustAccount, LogisticsPostalAddress(int64)
  • maintain relation :  Table.LogisticsPostalAddress == LogisticsPostalAddress.Recid.
  • Create a new form and add above data source
  • Under Design, Take NewControl stringedit for CustAccount 
  • override lookup 

public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource         qbds;
    QueryBuildRange                 queryBuildRange;
    SysTableLookup                   sysTableLookup;
    super();

    sysTableLookup         =  sysTableLookup::newParameters(tableNum(CustTable), this);
    sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum), true);
    qbds   = query.addDataSource(tablenum(CustTable));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}
  • then Again Take NewControl Reference group 
  • Set Properties for reference group

























  • Override LookupReference 

public Common lookupReference()
{
    CustTable                   custTable;
    DirPartyTable               dirPartyTable;
    DirPartyLocation            dirPartyLocation;
    LogisticsPostalAddress      logisticsPostalAddress;
    SysReferenceTableLookup     sysRefTableLookup;
    Query                       lookupQuery = new Query();
    QueryBuildDataSource        lookupQueryDataSource;

    // Construct the SysRefTableLookup object
    sysRefTableLookup = SysReferenceTableLookup::newParameters(tableNum(LogisticsPostalAddress), ReferenceGroup);

    // Add the field list that will be displayed on the lookup form
   // You can Change/Add more fields in lookup based on your requirement.

    sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Address));
    sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Location));

    // Construct the query's data source
    lookupQueryDataSource = lookupQuery.addDataSource(tableNum(LogisticsPostalAddress));

 // To add multiple values in range.
    while select  Location from LogisticsPostalAddress
        join DirPartyLocation
        join dirPartyTable
        join custTable
            where logisticsPostalAddress.Location == dirPartyLocation.Location
                && dirPartyLocation.Party == custTable.Party
                && custTable.Party == DirPartyTable.RecId
                && custTable.AccountNum == CustomerName.valueStr()
    {
        // Add ranges to the query data source
        lookupQueryDataSource.addRange(fieldNum(LogisticsPostalAddress, Location)).value(queryValue(LogisticsPostalAddress.Location));
    }


    // Pass the query to the lookup object
    sysRefTableLookup.parmQuery(lookupQuery);

    return sysRefTableLookup.performFormLookup();
}
  • Save and Run the Form