[FormDataSourceEventHandler(formDataSourceStr(SalesAgreementGenerateReleaseOrder, SalesCreateReleaseOrderTableTmp), FormDataSourceEventType::QueryExecuting)]
public static void SalesCreateReleaseOrderTableTmp_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)
{
sender.query().dataSourceName(sender.name()).addRange(fieldnum(SalesCreateReleaseOrderTableTmp,DlvMode)).value("X-Factory");
}
[FormControlEventHandler(formControlStr(SalesAgreementGenerateReleaseOrder, Delivery_DlvMode), FormControlEventType::Lookup)]
public static void Delivery_DlvMode_OnLookup(FormControl sender, FormControlEventArgs e)
{
QueryBuildDataSource queryBuildDataSource;
Query query = new Query();
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DlvMode), sender);
// Add the lookup columns
sysTableLookup.addLookupfield(fieldNum(DlvMode, Code));
sysTableLookup.addLookupfield(fieldNum(DlvMode, Txt));
// Add Range
queryBuildDataSource = query.addDataSource(tableNum(DlvMode));
queryBuildDataSource.addRange(fieldnum(DlvMode, Code)).value(queryValue("X-Factory"));
sysTableLookup.parmQuery(query);
// Run the lookup
sysTableLookup.performFormLookup();
//cancel the call to super() to prevent the system from trying to show
//the lookup form twice and cause an error.
FormControlCancelableSuperEventArgs cancelableSuperEventArgs = e as FormControlCancelableSuperEventArgs;
cancelableSuperEventArgs.CancelSuperCall();
}
public class SalesTableEventHandler
{
[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Initialized)]
public static void SalesLine_OnInitialized(FormDataSource _sender, FormDataSourceEventArgs _e)
{
var overrides = SalesTableFormExtensionOverrides::construct();
_sender.object(fieldNum(SalesLine, ItemId)).registerOverrideMethod(methodStr(FormDataObject, lookup),
methodStr(SalesTableFormExtensionOverrides, ItemId_OnLookup), overrides);
}
}
public class SalesTableFormExtensionOverrides
{
protected void new()
{
}
public static SalesTableFormExtensionOverrides construct()
{
return new SalesTableFormExtensionOverrides();
}
public void ItemId_OnLookup(FormStringControl _callingControl)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _callingControl);
sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));
sysTableLookup.performFormLookup();
}
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156