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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Create record from lookup field if record is not found

(1) ShareShare
ReportReport
Posted on by 311
Hello!
 
I am currently working with a lookup field, and is on the lookout for a solution to a problem I have, or at least see if there is a way to make it smoother for the user.
Working with other lookup fields, I am able to press the "New" button in the little popup table, and create a new record that way, but in the current lookup, I am facing an issue.
 
As you can see in the pictures below, I am not able to insert a value that does not exist in the table. In this case, that is the Dimension Value table. I know I can insert data into that table, but that is not what I am asking.
Is it possible to run a procedure, or anything before or after that error occurs, where I can ask the user if they want to insert the value into the table? Are there any triggers or anything I can listen to?
 
The field itself is just a normal Code[20] field with a TableRelation. It also has an OnValidate trigger, but I am pretty sure I don't get that far unless the value is okay.
 
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,739 Super User 2025 Season 2 on at
    Hi, try the following method to bypass the current error message.
    Dynamics 365 Business Central: How to use Try methods/functions (TryFunction Attribute)
     
    Hope this helps.
    Thanks.
    ZHU
  • Hagru Profile Picture
    311 on at
    Hi Yun Zhu!
     
    I was thinking about a TryFunction, but I could not figure out where to run it from. 
    Like I said, the field has an OnValidate trigger, but I only reach it when I click on one of the values suggested in the list. When I add a custom value, it won't get there. I also tried adding an OnBeforeValidate trigger to the field, but I'm not getting that far either, as it is not triggered.
     
    The error displayed is the same error as in any other field with a table relation, such as the default Business Central field Country/Region Code:
     
     
     
    I am just not sure where to handle that error, or if it is even possible.
  • Gerardo Rentería García Profile Picture
    25,360 Most Valuable Professional on at
  • Hagru Profile Picture
    311 on at
    I was looking into the ValidateTableRelation, but quickly figured out that won't be the way to go, as the property cannot be customized. The table in question is the Dimension Values table, which is standard Business Central, and the field I am using is part of an extension I don't currently have the code for, and am therefore unable to make changes to the origin of the field.
     
    I also don't want to mess around with adding another field, as I am sure the field I am using is a crucial one, and will be used a bunch of other places as well.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans