In our items table we have next to our no. column (No.) a second no. column (No. 2) with our old article numbers.
Now I need to display the No.2 entries in our sales reports.
I have created a table relation in the sales - line table (Table 37 Sales Line) and created a field in the sales - lines page (Page 516 Sales Lines).
Also I have added the field into the sales - quote report to check if it works, but neither the no.2 entries are displayed in the report nor I can add the no.2 column into the sales - quote form.
The no.2 column is visible in the sales - line table, but it's empty.
How can I create a table relation from the items table to the sales - line table?
*This post is locked for comments
It seems a license problem, to be able to access the code of the table you have to change the license to one with permission to develop, maybe a partner license.
Steps:
Tools > License Information > Change
And then select the correct developer license
Where do I have to add the code-snippet?
I can't add it to the table, since C/AL Code is disabled for tables (or at least I can't open it).
Hello,
TableRelation does not fill the field value automatically, more information here: docs.microsoft.com/.../tablerelation-property
I recommend you use the solution proposed by Hannes.
If you want to set the value in older lines you should make a ProcessOnly (it is a property) report with Table 37 (Sales Line) as a DataItem, and assign "No. 2" in OnAfterGetRecord trigger, example:
Sales Line - OnAfterGetRecord()
IF Type = Type::Item THEN IF Item.GET("No.") THEN BEGIN "No. 2" := Item."No. 2"; MODIFY; END;
Maybe it would be interesting to filter by date, since it will reduce the impact on performance:
hi,
You must fill the new field with data.
It's code similar like this:
Table 37, Field "No." - OnValidate() IF ItemRec.GET("No.") THEN "No. 2" := ItemRec."No. 2";
Keep in mind, this kind of code would transfer data into "No. 2" only for new records.
You would have to update existing records with a report or codeunit as an extra step.
PS: Alternativly, you could change the field definition to "FlowField". Then, NAV would lookup the value automatically. (But you cannot input data by yourself.)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156