Announcements
Hi ,
Can anyone help me on this.
How to open a dialog box with a lookup field from a form control event handler .
I didn't understood why registerOverride method is required in your code. Do you want to override Reason Code lookup that will be displayed in the dialog?
Regarding, lookup not visible after commenting code, as per your code EDT for Reason code is ReasonCode_CAP. I tried standard ReasonCode EDT which has Table relation to ReasonTable. In your case, what is the source table for ReasonCode?
I tried commenting the 3 lines as mentioned by you above but the lookup for reason code is not visible for me in the Dialog .
Yes, Harish already told us that the error is thrown by registerOverrideMethod() method. If we doesn't call it, he won't get the error, but he would also lose functionality.
Can you try commenting below 3 lines from your code
FormBuildStringControl control;
control = dfReasonCode.control();
control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);
I tried to use your code on standard fields and got below error when clicked on Reason code lookup in Dialog
And commenting that 3 lines seems to be working
Please never tell us just something like "it's throwing an error". Tell us what error you're getting. We can't help you if don't give us basic information.
Also, how is performFormLookup() defined?
Thanks Mohit for the reply.
Yes you are right need to display Dialog with Reason Code on why Sales price was modified.
Throwing error on Getting Error on registerOverrideMethod.
In the Line - control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);
Your another post is more clear, Please delete the duplicate post.
As per your code, I think you need to display Dialog with Reason Code on why Sales price was modified. Have you debugged the code and on which line its throwing error and what's the error?
No Actually when the on Modified event run ,a dialog will pop up with a drop down .
Hi Harish, Are you asking on how to override lookup method using form event handlers?
If yes, then check this out
public class ReasonCodeDialog_Cap
{
[FormControlEventHandler(formControlStr(SalesTable, SalesLine_SalesPrice), FormControlEventType::Modified)]
public static void SalesLine_SalesPrice_OnModified(FormControl sender, FormControlEventArgs e)
{
FormDataSource salesLine_ds = sender.formRun().dataSource("SalesLine");
SalesLine salesLine = salesLine_ds.cursor();
Dialog dlg = new Dialog();
ReasonMain_CAP reason_Cap;
PriceChangeHistory_Cap priceChangeHistory;
DialogField dfReasonCode = dlg.addField(extendedTypeStr(ReasonCode_CAP),'ReasonCode');
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tableNum(ReasonMain_CAP), sender);
sysTableLookup.addLookupField( fieldNum(ReasonMain_CAP,ReasonCode ));
queryBuildDataSource = query.addDataSource(tableNum(ReasonMain_CAP));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
FormBuildStringControl control;
control = dfReasonCode.control();
control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);
if (dlg.run())
{
if (dfReasonCode.value() != '' )
dlg.closedOk();
Getting Error on registerOverrideMethod.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator