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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Error on Lookup

(0) ShareShare
ReportReport
Posted on by
Hi I do have a lookup on a custom field on the sales table. It´s a lookup on a custom table
 
The lookup open like it should be, I can filter on all 4 Lookup fields but when I select a value I get an error that the value cannot be found
 
    sysTableLookup=SysTableLookup::newParameters(tablenum(CEM_CRM_Opportunity),this);    sysTableLookup.addLookupfield(fieldnum(CEM_CRM_Opportunity,Name));    sysTableLookup.addLookupfield(fieldnum(CEM_CRM_Opportunity,Opportunitynumber));    sysTableLookup.addLookupfield(fieldnum(CEM_CRM_Opportunity,StatusA));    sysTableLookup.addLookupfield(fieldnum(CEM_CRM_Opportunity,StatusB));    sysTableLookup.addLookupfield(fieldnum(CEM_CRM_Opportunity,OpportunityId));    qbds = query.addDataSource(tablenum(CEM_CRM_Opportunity));    sysTableLookup.parmQuery(query);    sysTableLookup.performFormLookup();
I open the lookup, filter on the name column and select the record.
 
Now the error comes up:
The value '52451 SKARPSKYTTEN, LUND' in field 'Opportunity Id' is not found in the related table 'Opportunity'.
 
I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    306,846 Super User 2026 Season 2 on at
    Hi Cembrit,
     
    It would be good to know where the value "52451 SKARPSKYTTEN, LUND" is coming from. Is this the opportunity name? 
    You can try changing the command for adding the lookup field for the Opportunity ID to a selection field. That will tell the lookup to use another field than the first one.
     
    sysTableLookup.addSelectionfield(fieldnum(CEM_CRM_Opportunity,OpportunityId)); 
     
     
     
  • Cembrit Profile Picture
    on at
    Hi Andre

    Yes the value "52451 SKARPSKYTTEN, LUND" is the name the user are filtering the lookup.

    Addid the addSelectionField does not change anything. the error still occurs
  • Martin Dráb Profile Picture
    240,521 Most Valuable Professional on at
    I guess that then problem is not in the lookup, but in what values are allowed for the table field (as defined by a table relation). Are you sure that the field has a relation to CEM_CRM_Opportunity? If so, which field is it related to?
     
    You can also test it by typing the value in the field without using a lookup. If it fails too, you'll know for sure that it has nothing to do with the lookup.
  • Cembrit Profile Picture
    on at
    Hi
     
    Entering the opportunity id (GUID from CRM System) directly works fine. 
     
     
  • Martin Dráb Profile Picture
    240,521 Most Valuable Professional on at
    OK, so you're saying that the value you selected in the lookup ('52451 SKARPSKYTTEN, LUND') is indeed invalid and it can't be used in the field. You're saying that you must use a GUID there, not something like '52451 SKARPSKYTTEN, LUND'.
     
    Unfortunately you haven't answer the question about the related field, therefore I can't tell us which field contains the GUID and therefore it needs to be returned by the lookup. Also, I think the a better design would be using a relation over RecId instead of the GUID, if it meets your other requirements. Then you can simply select the field group that should be shown in the lookup and the system will create the lookup; you won't need any code.
  • Cembrit Profile Picture
    on at
    I am sorry.
     
    The related field on the customized table is the guid (because it is the only unique field)
    The search in the lookup is easier by name that's where the text (52451...) comes from.

    The lookup contains multiple fields but when selection should be done on the responiding guid (opportunity id)
  • Suggested answer
    Martin Dráb Profile Picture
    240,521 Most Valuable Professional on at
    Then you must return the value of OpportunityId instead of Name. Use the second parameter of addLookupField():
    sysTableLookup.addLookupField(fieldNum(CEM_CRM_Opportunity, OpportunityId), true);
  • Suggested answer
    Cembrit Profile Picture
    on at
    sorry wrong post but am not able to delete it

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
SajeedMullaji Profile Picture

SajeedMullaji 760

#2
Martin Dráb Profile Picture

Martin Dráb 330 Most Valuable Professional

#3
CU10121822-0 Profile Picture

CU10121822-0 310

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans