Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How can I search by multiple fields in a lookup in D365FO?

(2) ShareShare
ReportReport
Posted on by 8

Hi everyone,

 

I'm trying to enable searching by multiple fields in a lookup in Dynamics 365 Finance and Operations, but I can't get it to work as expected.

 

Currently, the lookup only searches by the YuklemeYeriKoduStr field, but I also want it to search by the YuklemeYeriAdi field. I’ve tried using resolveAmbiguousReference and setting both fields, but the lookup still only filters by the first one.

 

Here is the relevant part of my code for the data field:

 

 [DataField]
 class YuklemeYeriKoduStr 
 {
     /// <summary>
     ///
     /// </summary>
     /// <param name = "_formControl"></param>
     /// <returns></returns>
     public str resolveAmbiguousReference(FormControl _formControl)
     {
         return FormControlAmbiguousReferenceResolver::resolveAmbiguousReferenceForControl (
 _formControl,
 true,
             AbsoluteFieldBinding::construct(fieldStr(YuklemeYeri, YuklemeYeriKoduStr),tableStr(YuklemeYeri)),
             AbsoluteFieldBinding::construct(fieldStr(YuklemeYeri, YuklemeYeriAdi),tableStr(YuklemeYeri)));
     }
     /// <summary>
     ///
     /// </summary>
     /// <param name = "_formControl"></param>
     /// <param name = "_filterStr"></param>
     public void lookup(FormControl _formControl, str _filterStr)
     {
         new InventLookup(_formControl, new Query(), formStr(YuklemeYeriLookup)).run();
     }
 }
 
 
 
And here is the code for the lookup form:
 
 
[Form]
public class YuklemeYeriLookup extends FormRun
{

    public void run()
    {
        FormStringControl lookupHostControl = SysTableLookup::getCallerStringControl(this.args());
        boolean isFiltered = SysTableLookup::filterLookupPreRun(lookupHostControl, YuklemeYeri_YuklemeYeriKoduStr, YuklemeYeri_ds);
        super();
        SysTableLookup::filterLookupPostRun(
        isFiltered,
        lookupHostControl.text(),
        YuklemeYeri_YuklemeYeriKoduStr, 
        YuklemeYeri_ds,
        new FormControlAmbiguousReferenceResolver(lookupHostControl),
        YuklemeYeri_YuklemeYeriAdi );
    }
}
 
 
Categories:
  • Martin Dráb Profile Picture
    235,043 Most Valuable Professional on at
    How can I search by multiple fields in a lookup in D365FO?
    @Ahmet Enes Can you give us more details about your implementation? For instance, what are title fields of your table? Do you have indexes for both fields?
  • Suggested answer
    udaY-ch Profile Picture
    5,051 on at
    How can I search by multiple fields in a lookup in D365FO?
    Hi
     
    Please find the reference belwo from AssetId look on the PurchTable form,
     
    Ref: AssetInvoiceLookup.run method
     public void run()
     {
         FormStringControl   formStringControl = SysTableLookup::getCallerControl(element.args()) as FormStringControl;
         boolean             filterLookup;
    
         canClose = true;
    
         if (formStringControl)
         {
             filterLookup = SysTableLookup::filterLookupPreRun(formStringControl, assetTable_AssetId, assetTable_ds);
    
             super();
    
             SysTableLookup::filterLookupPostRunEx(
                 filterLookup,
                 formStringControl.text(),
                 assetTable_AssetId,
                 assetTable_ds,
                 AssetDataInteractorFactory::useExistingOrCreateResolver(formStringControl),
                 assetTable_Name);
         }
         else
         {
             super();
         }
     }
     
    Please do use insert code snippet for code alignment. 
     
    If you found this answer helpful, please mark it as the verified solution. This helps others in the community find answers quickly. Thank you!
     
    Thanks
    Uday
     
  • Ahmet Enes Profile Picture
    8 on at
    How can I search by multiple fields in a lookup in D365FO?
    Thanks for your response.
    I’ve already reviewed the "Contextual data entry for lookups" documentation and tried the suggested steps, even experimented with a few variations, but unfortunately I still couldn’t achieve the desired result.
  • Martin Dráb Profile Picture
    235,043 Most Valuable Professional on at
    How can I search by multiple fields in a lookup in D365FO?
    Check out Contextual data entry for lookups first to understand how the feature works.
     
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Alireza Eshaghzadeh Profile Picture

Alireza Eshaghzadeh 799 Super User 2025 Season 2

#2
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 757 Super User 2025 Season 2

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 751 Super User 2025 Season 2

Product updates

Dynamics 365 release plans