How can I use lookupReference in dialog?

I’m not sure is it possible to use lookupReference in dialog field.

I make a new class that i want to use it. Here is my code.

public void Fld300_1_lookup()

{

FormReferenceControl formControl;

formControl = dlgAddress.dialog().formRun().controlCallingMethod();

Address = LogisticsLocationSelectionLookup::lookupAddressForm(formControl,

CustTable::find(dlgCustomer.value()),

conNull(),

false);

}

the lookup is fine but i cannot get return record. Any problem with my code? Please help.

Which line of your code doesn’t work as expected?

(Question moved from the Technical forum.)

Address = LogisticsLocationSelectionLookup::lookupAddressForm(formControl,

CustTable::find(dlgCustomer.value()),

conNull(),

false);

I don’t get return record from this code.

I see several methods there and it’s impossible to guess where you problem lies. Please use the debugger to isolate the problem.

Maybe dlgCustomer.value() doesn’t return any value. Maybe it returns a customer ID that doesn’t exist. Maybe everything is fine here and you should be debugging the code inside lookupAddressForm() instead.

I already debugged lookupAddressForm() and here is the code.

public static Common lookupAddressForm(FormReferenceControl _callerFormControl,

Common _entity,

container _roleTypes,

boolean _returnLocation,

container _inUseAddresses = conNull())

{

Common selectedRecord;

Args args;

FormRun formRun;

Form addressLookupForm = new Form(formStr(LogisticsPostalAddressLookup));

str context = strFmt("%1;%2;%3", con2StrUnlimited(_roleTypes), _returnLocation, con2StrUnlimited(_inUseAddresses));

args = new Args();

args.name(formStr(LogisticsPostalAddressLookup));

args.caller(_callerFormControl);

args.record(_entity);

args.parm(context);

// perform form lookup on the caller form control

formRun = ClassFactory::formRunClassOnClient(args);

_callerFormControl.performFormLookup(formRun);

selectedRecord = formRun.selectRecordModeSelectedRecord();

return selectedRecord;

}

I found difference when this method call on form and dialog. If it call on form debugger will stop on

_callerFormControl.performFormLookup(formRun);

and wait until I select a record. But when I call from dialog it continue running. I’m not sure why they are not the same.

I guess that when I call on form, it passed FormReferenceControl to this method but in dialog I cannot pass that class because in dialogfield it calls FormStringControl.

Any suggestion?

Aha, I see.

If you’re passing a wrong type of parameter to lookupAddressForm() (FromStringControl instead of FormReferenceControl), you shouldn’t be surprise that it doesn’t work.

Either change the type of your control or change your code.