Friday, November 17, 2017

Dynamics 365 - More than one form was opened at once for the lookup control


In case you want to override the default lookup on a field , pay attention to cancelSuperCall() call as well.


If we don’t call this method then a call is first made to the default lookup and then your lookup logic will be executed.

If we don’t cancel the super call , we end up with an error “More than one form was opened at once for the lookup control.” Here is an example of how to cancel the super call.

[FormControlEventHandler(formControlStr(ProjTable, MyTable_MyField), FormControlEventType::Lookup)]
public static void 
MyTable_MyFieldCTRL_OnLookup(FormControl _sender, FormControlEventArgs _eventArgs)
{
    FormControlCancelableSuperEventArgs eventArgs = _eventArgs as FormControlCancelableSuperEventArgs;
    eventArgs.CancelSuperCall();


    MyHelper::lookupMyField(_sender);
}

1 comment: