Microsoft Dynamics AX development

Archive for the ‘Enterprise Portal’ Category

Enterprise Portal: configuring lookup

You can override the dataSetLookup method of the field in the data source, to control the lookup behavior. Here is an example:

void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List                                list = new List(Types::String);
    LogisticsLocationSelectionLookup    logisticsLocationSelectionLookup;
    CustTable                           custTable;
    Common                              partyRecord;
    DirPartyLocation                    partyLocation;
    container                            locations;
    Query                               query = new Query();
    QueryBuildDataSource                qbdAddress;
   
    partyRecord = DirPartyPostalAddressFormHandler::getTransactionEntity(element.args().record());
    custTable = CustTable::find(salesTable.CustAccount);
 
    logisticslocationselectionlookup = logisticslocationselectionlookup::construct(partyrecord);
    logisticslocationselectionlookup.parmAllowAddAddress(false);
    logisticslocationselectionlookup.parmAllowEnhancedSelect(false);
    logisticslocationselectionlookup.parmUseLookupValue(true);
 
    logisticslocationselectionlookup.addRoleByType(LogisticsLocationRoleType::Delivery);
    logisticslocationselectionlookup.parmreturnlocation(true);
 
    while select Location from partyLocation
        where partyLocation.Party == custTable.Party
    {       
locations += partyLocation.Location;     }       qbdAddress = query.addDataSource(tablenum(LogisticsPostalAddress));     qbdAddress.fields().clearFieldList();     qbdAddress.addRange(fieldnum(LogisticsPostalAddress, Location)).value(con2str(locations));       //methods and fields of the LogisticsPostalAddress table     list.addEnd(tablemethodstr(LogisticsPostalAddress, getLocationName) + '**');//display method     list.addEnd(tablemethodstr(LogisticsPostalAddress, getDescription) + '**');//display method     list.addEnd(fieldStr(LogisticsPostalAddress, Street)); //field     list.addEnd(tablemethodstr(LogisticsPostalAddress, getDealerCode) + '**');//display method     list.addEnd(tablemethodstr(LogisticsPostalAddress, getExternalAddressCode) + '**');//display method       sysDataSetLookup.parmSelectField(tablemethodstr(LogisticsPostalAddress, getLocationNumber) + '**');       sysDataSetLookup.parmLookupFields(list);     sysDataSetLookup.parmQuery(query); }

The result is:

Capture

Tag Cloud