AL(AA0210) The table Item Journal Line does not contain the key with the field Operation No.

Created on 16 Sep 2019  Â·  3Comments  Â·  Source: microsoft/AL

Describe the bug
You get this warning when you filter on a field that does not have a key in the table. This is a good warning that I would like to see to improve my solution. However it is not very logical that you get this warning on Standard Tables with their standard fields because you can only create keys for fields that you have created.

To Reproduce
local procedure RegisterTimeRegistration(); var ItemJnlLine: record "Item Journal Line"; begin ItemJnlLine.setrange("Operation No.", 'test'); ItemJnlline.findfirst(); end;

Expected behavior
Only show the warning for New Tables or for Extension Fields.
OR give us the ability to add a key to standard fields. ( < we all prefer this solution)

Screenshots
image

Versions:

  • AL Language: 4.0.170493
  • Business Central: Dynamics.15x.BE.3359030.DVD
CodeCop bug bydesign in-progress static-code-analysis

Most helpful comment

So that's it? We are stuck with these warnings?
The code cop should not give a warning for things that are out of our hand.

All 3 comments

I was going to open a new ticket, but I think it is actually related to this one: we are also getting this error with keys that only include extension fields and for which there is a key in the table extension.

This is also on Yammer here: https://www.yammer.com/dynamicsnavdev/threads/343040592707584

I'm adding my comments here for visiblity:

Right now it:

  1. complains about BaseApp tables and fields that we cannot do anything about
  2. complains about Virtual System tables that we definitely cannot modify (like the Date table)
  3. has above issues
  4. throws errors in app.json:
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceParameterSymbol' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IVariableSymbol'.

   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex.AnalyzeInvocations(SyntaxNodeAnalysisContext syntaxNodeAnalysisContex, ImmutableDictionary`2 processInvocations) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule210SuboptimalIndex.cs:line 86

   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex.<>c.<Analyze>b__5_0(SyntaxNodeAnalysisContext syntaxNodeAnalysisContex) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule210SuboptimalIndex.cs:line 66

   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass52_1.<ExecuteSyntaxNodeAction>b__1() in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 742

   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1079'

I understand why this rule has been created, but having a rule with a lot of "false positives" does not help. Right now I've disabled this rule in our ruleset.json file.

But I would love a way to suppress individual problems, like the Diagnostics.CodeAnalysis.SuppressMessageAttribute attribute in PowerShell.

So that's it? We are stuck with these warnings?
The code cop should not give a warning for things that are out of our hand.

Was this page helpful?
0 / 5 - 0 ratings