Microsoft Dynamics AX development

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);
    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:



Comments on: "Enterprise Portal: configuring lookup" (2)

  1. Jessica Roybal said:

    Where did you override the dataSetLookup method? Did you do this on the EPSalesTableCreate dataset SalesTable datasource DeliveryPostalAddress field? Also it appears like “getLocationName” is not a method on the LogisticsPostalAddress table, did you create new display methods on that table or somewhere else?

    • Hi Jessica!
      I have created the method on the EPSalesTableCreate dataSource on the DeliveryPostalAddress field!
      You can copy the code that I’ve posted.
      The method does not appear in the override method list, but you can create it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: