For a custom development I have to use the LogisticsLocationSelect form layout as a lookup form for a location on an extension of Delivery Mode. I overrode the lookupReference method of the added field in DeliveryMode form and typed the following code (see code). However this does not work as I expected. When i click OK in the lookup form everything works fine, but when i click a customer/vendor/... the form immediately closes and gives a warning (form goes throught the CloseOk() method even though I didn't click OK).
So an easy fix for this (imo) would be to have the form only be able to close on clicking OK or cancel and not when selecting any record. Is this possible? I only started working with D365 3 months ago, so forgive me if this is a stupid question.
Code as I have it now:
public Common customLookupReference(FormReferenceControl _formReferenceControl)
{
Common ret;
DlvMode dlvMode;
dlvMode = DlvMode_ds.cursor();
ATSLogisticsLocationSelectForm_DlvMode selectForm = new ATSLogisticsLocationSelectForm_DlvMode(dlvMode);
Args args = new Args();
args.parm(any2Str(dlvMode.ATSLogisticsPostalAddressRecId));
args.name(formStr(LogisticsLocationSelect));
args.parmObject(selectForm);
FormRun formRun;
Form addressLookupForm = new Form(formStr(LogisticsLocationSelect));
formRun = ClassFactory::formRunClassOnClient(args);
//works well if you navigate to the desired address using tab and arrows and then click the OK button when you are on the desired record
//however, gives a warning when you click on anything to select the desired address
//TO DO: make sure this form can only be closed using the ok or cancel buttons
_formReferenceControl.performFormLookup(formRun);
ret = formRun.selectRecordModeSelectedRecord();
return ret;