web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Data entity lookup up of a field issue

(6) ShareShare
ReportReport
Posted on by 351
Hi,
 
I am trying to add lookup for a field CompanyLocation in my entity .It is a custom entity and I tried to get lookup for the field. When I try to get the locationId from LogisticsLocation, it is working , but I want the description also.
My questions:
1. Can I add 2 fields in lookup (Location Id and Description )? 
2. If not how can I add description in lookup . When i tried just description it shows nothing. But the same is working if I locationID. Am i missing anything?
 
Please see my lookup method added to the entity.
 
 [
     SysODataAction("NewVendInvoiceJournalLineEntityCompanyLocMappedCustomLookup", false),
     SysODataCollection("_fields", Types::String),
    SysODataFieldLookup(fieldStr(NewVendInvoiceJournalLineEntity, LocationIdCompany))
 ]
 public static str companyLocMappedCustomLookup(Array _fields)
 {
     // Field to return
     RefFieldName companyLocFld = fieldStr(NewVendInvoiceJournalLineEntity, LocationIdCompany);

     // Map fields for Office Add-in
     Map fieldMap = OfficeAppCustomLookupHelper::getFieldMap(
     tableStr(NewVendInvoiceJournalLineEntity),
     _fields
 );

     OfficeAppCustomLookupListResult result = new OfficeAppCustomLookupListResult();
     result.determinationFields().value(1, companyLocFld);

     LogisticsLocation logisticsLoc;
     int counter = 1;

     // Build lookup items
     while select Description,locationId from  logisticsLoc order by locationId
     {
       //  result.items().value(counter, logisticsLoc.Description);
         result.items().value(counter, logisticsLoc.LocationId);
         counter++;
     }

     return result.serialize();

 }
 
 
Please help.
 
Thanks,
Priya
Categories:
I have the same question (0)
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,495 Super User 2026 Season 1 on at
    Hi PriyaDutta,
     
    In the while select in the above code snippet you can try including something like this. Just tried the code snippet with map.exists() method. 
    while select Description, LocationId from logisticsLoc order by LocationId
    {
       // First Column - Location Id
       if (fieldMap.exists(fieldStr(LogisticsLocation, LocationId)))
       {
          result.items().value(counter, logisticsLoc.LocationId, fieldMap.lookup(fieldStr(LogisticsLocation, LocationId)));
       }
    
       else
       {
          result.items().value(counter, logisticsLoc.LocationId);
       }
    
       // Second column - Description
       if (fieldMap.exists(fieldStr(LogisticsLocation, Description)))
       {
          result.items().value(counter, logisticsLoc.Description, fieldMap.lookup(fieldStr(LogisticsLocation, Description)));
       }
    
       else
       {
          result.items().value(counter, logisticsLoc.Description);
       }  
    
       counter++;
    }
    Hope this helps. Happy to answer questions, if any.
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 545 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 408

#3
Adis Profile Picture

Adis 267 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans