For some reason, the external item field on these forms do not have lookups. If you want to set the external item manually, you would need a lookup on the field. Standard AX allows the user to type any string into the externalItemId field, it doesn't actually have to be in the external item table. We had a requirement to keep that functionality. If you wanted to limit the selection to only the items in the table you would need to add a relation on the salesLine, salesquotationline, and purchline tables to the CustVendExternalItem table and make sure validation is set to yes.
Doing this is not all that difficult. First you need to create a lookup on the custVendExternalItem table and then override the lookup on the form(s) you want to use it.
1. Here is the lookup code on the custVendExternalItem table
[ExtensionOf(tableStr(CustVendExternalItem))]
final class ModelCustVendExternalItem_Extension
{
public static void modelLookupExternalItem(FormControl _formControl, CustVendRel _accountNum, ItemId _itemid)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustVendExternalItem),_formControl);
sysTableLookup.addLookupfield(fieldNum(CustVendExternalItem, ExternalItemId),true);
sysTableLookup.addLookupfield(fieldNum(CustVendExternalItem, ItemId));
sysTableLookup.addLookupfield(fieldNum(CustVendExternalItem, CustVendRelation));
qbds = query.addDataSource(tableNum(CustVendExternalItem));
qbds.addRange(fieldNum(CustVendExternalItem, custvendrelation)).value(_accountNum);
qbds.addRange(fieldNum(CustVendExternalItem, ItemId)).value(_itemid);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
No comments:
Post a Comment