← Back to Benchmark Results

openrouter/x-ai/grok-code-fast-1

66.1%
Pass Rate
37/56
Tasks Passed
3
Runs
57.7%
pass@1
66.1%
pass@3
83.9%
Consistency
0.1
Temperature
-
Thinking
706,774
Tokens
$7.49
Cost
1st: 732nd: 24Failed: 1937/56 passed

Known Shortcomings (22)

Sorted by occurrence count (most frequent first)

# Concept AL Concept Count Affected Tasks
1 query-object-syntax query-definition 2 CG-AL-H011, CG-AL-H017

Description: The model failed to generate valid AL code for a query object. The compilation errors (AL0107 'identifier expected' at line 27:32, AL0104 '=' expected, etc.) indicate the model produced syntactically invalid AL for the query definition. The generated code was either empty or had fundamental syntax errors in the query structure, likely around the filter element or column definitions. The model doesn't properly know how to construct an AL query object with dataitem, columns with Method = Sum/Count, filter elements with ColumnFilter, and OrderBy clauses.

Correct Pattern:
query 70011 "CG Sales Summary"
{
    QueryType = Normal;
    OrderBy = ascending(Sell_to_Customer_No);

    elements
    {
        dataitem(SalesLine; "Sales Line")
        {
            column(Document_No; "Document No.") { }
            column(Sell_to_Customer_No; "Sell-to Customer No.") { }
            column(Line_Amount_Sum; "Line Amount") { Method = Sum; }
            column(Line_Count; "Line Amount") { Method = Count; }
            filter(Document_Type; "Document Type") { ColumnFilter = const(Order); }
        }
    }
}
Incorrect Pattern:
// Generated code not found - but compilation errors at line 27 suggest the model produced a query with syntax errors around filter/column definitions

Error Codes: AL0107, AL0104

2 jsonobject-selecttoken-vs-get json-api-usage 2 CG-AL-M020, CG-AL-H014

Description: The model incorrectly used JsonObject.Get() by passing typed variables (Text, Decimal, Boolean, Integer, JsonArray) directly as the second argument, but JsonObject.Get() expects a 'var JsonToken' as the second parameter. The correct pattern is to first get a JsonToken, then extract the value from the JsonToken via AsValue().AsText(), AsValue().AsDecimal(), AsArray(), etc. The model also tried to use 'foreach' on a JsonArray directly, which is not supported — you must iterate using an index-based loop with JsonArray.Get(Index, JsonToken). These are fundamental AL JSON API patterns the model failed to apply correctly.

Correct Pattern:
var JToken: JsonToken; JValue: JsonValue;
ProductJson.Get('name', JToken);
JValue := JToken.AsValue();
NameText := JValue.AsText();

ProductJson.Get('price', JToken);
PriceDecimal := JToken.AsValue().AsDecimal();

// For arrays:
ProductJson.Get('values', JToken);
ValuesArray := JToken.AsArray();
for i := 0 to ValuesArray.Count - 1 do begin
  ValuesArray.Get(i, JToken);
  Sum += JToken.AsValue().AsInteger();
end;
Incorrect Pattern:
ProductJson.Get('name', NameText); ProductJson.Get('price', PriceDecimal); ProductJson.Get('inStock', InStockBool); ProductJson.Get('quantity', QuantityInt);

Error Codes: AL0133

3 httpclient-getheaders-usage http-client-api 2 CG-AL-M005, CG-AL-M022

Description: The model generated code that calls GetHeaders() without the required HttpHeaders parameter. In AL, HttpRequestMessage.GetHeaders(var HttpHeaders) and HttpContent.GetHeaders(var HttpHeaders) require an HttpHeaders variable to be passed as a VAR parameter. The model likely wrote something like `Request.GetHeaders().Add(...)` instead of declaring an HttpHeaders variable and passing it: `Request.GetHeaders(Headers); Headers.Add(...)`. This is a common pattern misunderstanding with the AL HttpClient API where GetHeaders is not a function that returns headers directly but rather populates a VAR parameter.

Correct Pattern:
var Headers: HttpHeaders;
...
Request.GetHeaders(Headers);
Headers.Add('Authorization', 'Bearer ' + AuthToken);
Incorrect Pattern:
Request.GetHeaders().Add(...) or similar calls without passing the required HttpHeaders VAR parameter

Error Codes: AL0135, AL0122

4 multiline-string-literals string-literals 1 CG-AL-E050

Description: The model failed to correctly use AL multiline string literals. The compilation errors (AL0361 'Identifier was not properly terminated', syntax errors about semicolons and expected tokens on consecutive lines) strongly indicate the model attempted to use a multiline string syntax that is not valid in AL. In AL, multiline text literals were introduced in later runtime versions and use a specific syntax (text enclosed in single quotes with actual line breaks, or using TextBuilder/string concatenation). The model likely tried to use double-quoted multiline strings or some other language's multiline syntax (e.g., Python triple quotes or C# verbatim strings), which caused the parser to fail at line 8-11 of the generated file. The task specifically requires multiline string literals, which in AL (runtime 11.0+) use single-quote delimited strings that span multiple lines.

Correct Pattern:
In AL (runtime 11.0+), multiline string literals use single quotes spanning multiple lines, e.g.:

procedure GetSqlQuery(): Text
begin
    exit(
        'SELECT CustomerNo, Name, Balance' + Environment.NewLine() +
        'FROM Customer' + Environment.NewLine() +
        'WHERE Active = true' + Environment.NewLine() +
        'ORDER BY Name'
    );
end;

Or if the runtime supports it, use the actual multiline text constant syntax with single quotes.
Incorrect Pattern:
The generated code was not captured, but based on errors at lines 8-11 involving unterminated identifiers and missing semicolons, the model likely wrote something like: exit("SELECT CustomerNo, Name, Balance\nFROM Customer\nWHERE Active = true\nORDER BY Name"); using double quotes or an invalid multiline syntax.

Error Codes: AL0361

5 page-extension-cardpageid-override page-extension-properties 1 CG-AL-E053

Description: The model failed to generate valid AL code for a page extension. The compilation errors at line 3 and line 15 suggest the model produced syntactically invalid code, likely struggling with the BC 2025 Wave 1 feature of overriding CardPageId on a list page extension. The errors indicate fundamental syntax problems - missing semicolons, unexpected tokens, and unrecognized object keywords - meaning the model either produced malformed page extension syntax or attempted to use an incorrect syntax for the CardPageId property override. The correct pattern requires a standard pageextension declaration with the CardPageId property set at the extension level, plus an action in the actions section.

Correct Pattern:
pageextension 70053 "CG Item List Extension" extends "Item List"
{
    CardPageId = "Item Card";

    actions
    {
        addlast(Processing)
        {
            action("Show Item Details")
            {
                ApplicationArea = All;
                Caption = 'Show Item Details';
                Image = Card;
                RunObject = page "Item Card";
                RunPageLink = "No." = field("No.");
            }
        }
    }
}
Incorrect Pattern:
// Generated code not found - but errors at line 3:22 and 15:25 suggest malformed pageextension declaration with incorrect syntax for CardPageId override

Error Codes: AL0104

6 json-api-methods json-object-manipulation 1 CG-AL-H014

Description: The model generated code with multiple errors related to AL's JsonObject and JsonToken API usage: (1) AL0133 - Tried to pass a Text to a Boolean parameter, likely misusing a method overload. (2) AL0135 - Called JsonObject.Get(Text) without the required second 'var JsonToken' parameter - the correct signature is Get(Text, var JsonToken). (3) AL0132 - Tried to call 'AsDecimal' on JsonToken, but JsonToken doesn't have AsDecimal directly; you need to convert to JsonValue first via AsValue().AsDecimal(). The task description mentions 'typed JSON getter methods' like GetText(), GetInteger(), GetBoolean(), GetArray() which don't exist as direct methods on JsonObject in AL. The model needed to use the pattern: JsonObject.Get('key', JsonToken) then JsonToken.AsValue().AsText()/AsInteger()/AsDecimal() etc. The task description itself is somewhat misleading by referencing methods like GetText('name') that don't exist in AL's JSON API, but the model should have known the correct AL JSON patterns regardless.

Correct Pattern:
var JToken: JsonToken; JValue: JsonValue; begin CustomerJson.Get('name', JToken); JValue := JToken.AsValue(); NameText := JValue.AsText(); // For nested: RootJson.Get('data', JToken); DataObj := JToken.AsObject(); DataObj.Get('details', JToken); DetailsObj := JToken.AsObject(); DetailsObj.Get('amount', JToken); exit(JToken.AsValue().AsDecimal());
Incorrect Pattern:
Not available - generated code file was not found, but errors indicate incorrect JsonObject.Get() calls without var JsonToken parameter, incorrect boolean conversion, and JsonToken.AsDecimal() usage

Error Codes: AL0133

7 recordref-fieldref-dynamic-manipulation RecordRef-FieldRef-usage 1 CG-AL-H022

Description: The model generated code with syntax errors (semicolon expected at multiple lines around 101, 104, 128, 131). The generated code was not captured in the output, but the compilation errors indicate the model produced invalid AL syntax in the codeunit implementation. The errors at lines 101, 104, 128, 131 suggest issues in procedure bodies - likely incorrect statement termination, possibly using incorrect syntax for try/catch patterns (e.g., using 'try' or 'catch' keywords incorrectly), or malformed if-then-else blocks. The task and tests are valid; the model simply failed to produce syntactically correct AL code for the dynamic record handler codeunit.

Correct Pattern:
In AL, error handling uses [TryFunction] attribute on procedures or if not RunResult := Codeunit.Run() pattern. There is no try/catch syntax. Statements must end with semicolons. Example for safe RecordRef.Open: procedure GetTableName(TableId: Integer): Text; var RecRef: RecordRef; begin if not TryOpenTable(RecRef, TableId) then exit(''); exit(RecRef.Name); end; [TryFunction] local procedure TryOpenTable(var RecRef: RecordRef; TableId: Integer) begin RecRef.Open(TableId); end;
Incorrect Pattern:
// Generated code not captured, but compilation errors at lines 101, 104, 128, 131 indicate semicolon-expected errors, likely from incorrect error handling syntax or malformed control flow statements

Error Codes: AL0111

8 interface-and-implementation-syntax interface-definition 1 CG-AL-M009

Description: The model generated AL code with syntax errors at line 100, likely involving incorrect return type syntax or procedure signatures in the interface/implementation. The compilation errors (expecting ')', 'end', and semicolons at the same line) suggest the model wrote malformed procedure signatures, possibly using incorrect syntax for return types (e.g., Text[50] as a return type in a procedure declaration) or other structural issues in the codeunit implementing the interface. The task and tests are valid - the test file uses a separate mock codeunit and simply validates the interface contract. The model failed to produce syntactically correct AL code for the interface definition and/or its implementation.

Correct Pattern:
interface "Shipping Provider"
{
    procedure CalculateShippingCost(Weight: Decimal; FromCountry: Text; ToCountry: Text): Decimal;
    procedure EstimateDeliveryTime(FromCountry: Text; ToCountry: Text; ServiceType: Text): Integer;
    procedure CreateShipment(OrderNumber: Text; FromAddress: Text; ToAddress: Text; Weight: Decimal): Text[50];
    procedure TrackShipment(TrackingNumber: Text): Text[100];
    procedure ValidateAddress(Street: Text; City: Text; State: Text; ZipCode: Text; Country: Text): Boolean;
}

codeunit 70004 "Standard Shipping Provider" implements "Shipping Provider"
{
    // ... proper implementation of all interface methods
}
Incorrect Pattern:
Generated code not available but line 100 has syntax errors suggesting malformed procedure signature, likely something like: procedure CreateShipment(...): Text[50] with incorrect syntax

Error Codes: AL0104

9 jsonobject-get-returns-jsontoken json-handling 1 CG-AL-M021

Description: The model generated code that passes Text variables directly as the second argument to JsonObject.Get(), but JsonObject.Get() requires a 'var JsonToken' parameter. The model should have used a JsonToken variable, then extracted the text value from the token using AsValue().AsText(). Additionally, the model tried to call JsonObject.Set() which doesn't exist - the correct method is Replace() for existing keys or Add() for new keys.

Correct Pattern:
var JToken: JsonToken;
JsonObj.Get('name', JToken);
NameValue := JToken.AsValue().AsText();
// For setting values, use JsonObj.Replace(Key, Value) or JsonObj.Add(Key, Value)
Incorrect Pattern:
JsonObj.Get('name', NameValue); // where NameValue is Text
JsonObj.Set(...);

Error Codes: AL0133, AL0519

10 string-numeric-extraction-and-padding text-manipulation-number-formatting 1 CG-AL-E051

Description: The model generated code that fails to properly extract the numeric portion from a string, increment it, and re-insert it with the original zero-padding preserved. The error 'Expected:<DOC-002> Actual:<DOC- 2>' shows the model is replacing the numeric portion with a space-padded number instead of zero-padded. The model likely used Format() or a similar function that produces space-padded output instead of properly using PadStr or StrSubstNo with zero-padding, or manually constructing the zero-padded string. The model needs to: 1) Find the trailing numeric portion of the string, 2) Record its length for zero-padding, 3) Parse it as an integer, 4) Increment/decrement, 5) Format the result back with leading zeros to match the original width, 6) Concatenate with the prefix.

Correct Pattern:
To zero-pad in AL, use PadStr('', NumLen - StrLen(Format(NewNum)), '0') + Format(NewNum), or manually build the zero-padded string. For example: NumText := Format(NewNum); while StrLen(NumText) < OriginalNumLen do NumText := '0' + NumText; Result := Prefix + NumText;
Incorrect Pattern:
// Generated code not found - but based on error output, the model produced code that formats numbers with space padding instead of zero padding, e.g., Format(NewNum, NumLen) which produces '  2' instead of '002'
11 foreach-loop-continue-pattern loop-constructs-and-list-iteration 1 CG-AL-H013

Description: The model generated incorrect code for the SumPositiveNumbers procedure. Based on the test output, the sum returned 30 instead of 60 for inputs [10, 20, 30], suggesting the model's implementation only summed the last element or had a logic error such as reassigning instead of accumulating (e.g., using ':=' instead of '+='). The generated code was not captured but all tests failed, indicating fundamental implementation errors across all three procedures. The model failed to correctly implement foreach loops with continue statements, proper accumulation patterns, and comma-separated string building with arrays.

Correct Pattern:
procedure SumPositiveNumbers(Numbers: List of [Decimal]): Decimal
var
    Number: Decimal;
    Sum: Decimal;
begin
    foreach Number in Numbers do begin
        if Number <= 0 then
            continue;
        Sum += Number;
    end;
    exit(Sum);
end;
Incorrect Pattern:
// Generated code not found - but based on error 'Expected:<60> Actual:<30>' for inputs [10,20,30], the model likely wrote something like: Sum := Number; instead of Sum := Sum + Number; or had an off-by-one/logic error in the loop
12 complex-report-with-mock-codeunit report-definition-and-helper-codeunit 1 CG-AL-M007

Description: The model failed to generate valid AL code for a complex task requiring both a Report object (Sales Performance Analysis, ID 70001) and a helper codeunit (CG-AL-M007 Mock Calculator) used by the tests. The compilation errors at line 274 indicate a syntax error in the generated code - likely the model produced malformed AL syntax (possibly mixing object definitions incorrectly, using wrong delimiters, or failing to properly structure one of the required objects). The errors AL0104 ('Syntax error, ':' expected', 'Syntax error, ';' expected') and AL0198 ('Expected one of the application object keywords') suggest the model produced code that broke the AL parser, possibly by including invalid syntax within a procedure body or object definition, or by failing to properly close an object before starting another one.

Correct Pattern:
The task requires generating: 1) A Report 70001 'Sales Performance Analysis' with Customer, Sales Header, and Sales Line data items, request page with date filters, and proper triggers; 2) A Codeunit 'CG-AL-M007 Mock Calculator' with procedures: Initialize(), AddSalesLine(CustomerCode, Region, ItemCode, Quantity, Amount), GetRunningTotalByCustomer(CustomerCode): Decimal, GetRunningTotalByRegion(Region): Decimal, CalculateAverageOrderValue(): Decimal, GetCustomerRank(CustomerCode): Integer, GetTopProduct(): Text, GetProductSalesQuantity(ItemCode): Decimal, CalculateYoYComparison(CurrentYear, PreviousYear): Decimal, CalculateOrderFrequency(OrderCount, Days): Decimal, GetTotalSales(): Decimal, GetCustomerCount(): Integer. All objects must have proper AL syntax with correct object declarations, variable sections, and procedure definitions.
Incorrect Pattern:
Generated code not available (line 274 area has syntax errors suggesting malformed variable declaration, procedure definition, or object structure)

Error Codes: AL0104

13 event-subscriber-table-definition event-subscriber 1 CG-AL-E010

Description: The model generated a Table object named 'Item' (which conflicts with the existing Item table in the Base Application) instead of just creating a codeunit with an event subscriber. The AL0197 error confirms the model declared a 'Table' named 'Item', and the AL0275 errors are all cascading ambiguous reference errors because there are now two 'Item' tables. Additionally, the event subscriber parameter type didn't match (AL0284) because the subscriber was referencing the wrong/ambiguous Item table. The model should have created only a codeunit (70001) that subscribes to the existing Item table's OnAfterInsertEvent without defining any new table object.

Correct Pattern:
codeunit 70001 "Item Event Subscriber"
{
    Access = Internal;

    [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterInsertEvent', '', false, false)]
    local procedure OnAfterInsertItem(var Rec: Record Item; RunTrigger: Boolean)
    begin
        Message('New item created: %1', Rec."No.");
    end;
}
Incorrect Pattern:
An application object of type 'Table' with name 'Item' is already declared (the model created a table definition for Item instead of just subscribing to the existing one)

Error Codes: AL0197

14 multiline-string-literals string-operations 1 CG-AL-E050

Description: The model failed to generate valid AL code for multiline string literals. The compilation errors (AL0361 - unterminated identifier, plus numerous syntax errors on subsequent lines) indicate the model likely attempted to use a multiline string syntax that doesn't exist in AL, or used incorrect quoting/escaping. In AL, multiline text literals can be expressed using the text constant with line breaks inserted via character codes (e.g., using a TextBuilder or concatenation with CR/LF characters), or in newer AL versions using the verbatim string literal syntax. The model appears to have produced code with raw multiline strings or incorrect string delimiters that the AL compiler cannot parse.

Correct Pattern:
procedure GetSqlQuery(): Text
var
    CrLf: Text[2];
begin
    CrLf[1] := 13;
    CrLf[2] := 10;
    exit('SELECT CustomerNo, Name, Balance' + CrLf + 'FROM Customer' + CrLf + 'WHERE Active = true' + CrLf + 'ORDER BY Name');
end;

Alternatively, if the AL compiler version supports it, use the multiline string literal syntax with leading pipe characters or the appropriate AL syntax for verbatim strings.
Incorrect Pattern:
// Generated code not found - but compilation errors on lines 8-11 suggest raw multiline strings or improperly terminated string literals were used

Error Codes: AL0361

15 dictionary-iteration-syntax dictionary-type-usage 1 CG-AL-H018

Description: The model generated code that iterates over a Dictionary of [Text, Text] using invalid syntax. At line 80, it used 'Key' in a context that is not valid AL syntax. In AL, to iterate over a Dictionary you must use the Dictionary.Keys() method to get a List of keys, then use a foreach loop over that list. The model likely wrote something like 'foreach Key in RequestHeaders' or used 'Key' as a variable name in an invalid expression context, resulting in AL0519 ('Key' is not valid value in this context).

Correct Pattern:
var Keys: List of [Text]; HeaderKey: Text; HeaderValue: Text; begin RequestHeaders.Keys(Keys); foreach HeaderKey in Keys do begin RequestHeaders.Get(HeaderKey, HeaderValue); // use HeaderKey and HeaderValue end;
Incorrect Pattern:
Key (at line 80 - likely something like 'foreach Key : Value in RequestHeaders' or similar invalid dictionary iteration syntax)

Error Codes: AL0519

16 inherent-entitlements-permissions-values codeunit-properties 1 CG-AL-H019

Description: The model used 'Include' as the value for InherentEntitlements and InherentPermissions properties, but 'Include' is not a valid permission value in AL. The valid values for these properties are X (Execute), R (Read), I (Insert), M (Modify), D (Delete), or combinations thereof. The task specifies 'InherentEntitlements = X' and 'InherentPermissions = X', meaning Execute permissions. The model likely confused the syntax or used an incorrect identifier.

Correct Pattern:
InherentEntitlements = X;
InherentPermissions = X;
Incorrect Pattern:
InherentEntitlements = Include;
InherentPermissions = Include;

Error Codes: AL0776

17 dictionary-iteration-syntax collections-dictionary-foreach 1 CG-AL-H020

Description: The model used 'Key' as a variable name or keyword incorrectly when iterating over Dictionary entries. In AL, to iterate over dictionary keys you must use the Dictionary.Keys() method to get a List of keys, then iterate over that list with a foreach loop. The model likely wrote something like 'foreach Key in Dict' or used 'Key' as an undeclared identifier at lines 48 and 83, causing AL0519 ('Key' is not valid value in this context) and subsequent syntax errors. The correct pattern is to declare a variable for the key, call Dict.Keys() to get a List, and iterate with 'foreach KeyVar in KeyList do'.

Correct Pattern:
var
    KeyVar: Text;
    KeyList: List of [Text];
begin
    KeyList := Dict.Keys();
    foreach KeyVar in KeyList do begin
        // process KeyVar
    end;
end;
Incorrect Pattern:
Key in Dict (approximate - using 'Key' as undeclared identifier in foreach or similar construct at lines 48 and 83)

Error Codes: AL0519

18 codeunit-basic-structure codeunit-definition 1 CG-AL-H022

Description: The model failed to generate valid AL code for the codeunit. The generated code file was either empty or contained fundamentally broken AL syntax (semicolon expected errors at lines 11 and 14, and missing closing brace). The compilation errors (AL0111 semicolon expected, AL0104 '}' expected, AL0198 expected application object keyword) indicate the model produced malformed AL code that doesn't follow basic codeunit structure. The task and tests are valid - the model simply failed to produce syntactically correct AL code for a codeunit with RecordRef/FieldRef operations.

Correct Pattern:
codeunit 70224 "CG Dynamic Record Handler"
{
    Access = Public;

    procedure GetTableName(TableId: Integer): Text
    var
        RecRef: RecordRef;
        TableName: Text;
    begin
        if not TryOpenTable(RecRef, TableId) then
            exit('');
        TableName := RecRef.Name;
        RecRef.Close();
        exit(TableName);
    end;

    // ... other procedures following standard codeunit syntax
}
Incorrect Pattern:
// Generated code not found - the model produced malformed code with syntax errors at basic structural level

Error Codes: AL0111

19 bitwise-vs-logical-or-operator al-operators 1 CG-AL-M009

Description: The model generated code that uses the 'or' operator with Integer operands (likely trying to do bitwise OR or combining boolean conditions incorrectly). In AL, the 'or' operator is a logical operator that only works with Boolean operands. The model likely wrote something like 'if condition1 or condition2' where condition1 and condition2 evaluate to Integer rather than Boolean, or attempted to use 'or' as a bitwise operator on integers. The error occurs at line 133 of the generated file. The model should have used proper Boolean expressions or comparison operators to produce Boolean operands before applying 'or'.

Correct Pattern:
In AL, 'or' only works with Boolean operands. Use comparison operators to produce Boolean values, e.g.: (SomeInteger > 0) or (AnotherInteger > 0). For bitwise operations, AL does not support bitwise OR with the 'or' keyword on integers.
Incorrect Pattern:
// Line 133 likely contains something like: SomeIntegerValue or AnotherIntegerValue

Error Codes: AL0175

20 page-extension-cardpageid-override page-extension-syntax 1 CG-AL-E053

Description: The model failed to generate valid AL code for the page extension. The compilation errors at line 3 and line 15 suggest the model produced syntactically invalid code, likely struggling with the BC 2025 Wave 1 feature of overriding CardPageId on a page extension. The model either didn't know the correct syntax for this new feature or produced malformed AL code entirely. The 'Generated code not found' note and the numerous syntax errors (expecting ';', '}', integer literals, identifiers) indicate the model produced something that doesn't parse as a valid AL page extension object.

Correct Pattern:
pageextension 70053 "CG Item List Extension" extends "Item List"
{
    CardPageId = "Item Card";

    actions
    {
        addlast(Processing)
        {
            action("Show Item Details")
            {
                ApplicationArea = All;
                Caption = 'Show Item Details';
                Image = Card;
                RunObject = page "Item Card";
                RunPageLink = "No." = field("No.");
            }
        }
    }
}
Incorrect Pattern:
// Generated code not found - but compilation errors suggest malformed pageextension syntax at lines 3 and 15

Error Codes: AL0104

21 list-of-type-syntax generic-type-syntax 1 CG-AL-M023

Description: The model failed to generate valid AL code (generated code was not found/empty or had fundamental syntax errors). The compilation errors all point to syntax issues around '[' and ']' characters, which strongly suggests the model incorrectly used generic type syntax like 'List of [Text]' or 'List of [Code[20]]'. In AL, these types use square brackets as part of the syntax (e.g., 'List of [Text]'), and the model likely either omitted them, used angle brackets, or otherwise malformed the generic type declarations. The errors at multiple lines involving '[' expected and ']' expected confirm the model didn't properly handle AL's generic collection type syntax (List of [Type]) and possibly Code[20] field type syntax within return types and parameters.

Correct Pattern:
procedure GetCustomerNames(): List of [Text]
var
    Customer: Record Customer;
    Names: List of [Text];
begin
    Customer.SetLoadFields(Name);
    if Customer.FindSet() then
        repeat
            Names.Add(Customer.Name);
        until Customer.Next() = 0;
    exit(Names);
end;

procedure GetHighValueItems(MinPrice: Decimal): List of [Code[20]]
var
    Item: Record Item;
    Result: List of [Code[20]];
begin
    Item.SetLoadFields("No.", "Unit Price");
    if Item.FindSet() then
        repeat
            if Item."Unit Price" >= MinPrice then
                Result.Add(Item."No.");
        until Item.Next() = 0;
    exit(Result);
end;
Incorrect Pattern:
// Generated code not found - but errors indicate malformed List of [Text], List of [Code[20]] syntax

Error Codes: AL0104

22 trigger-side-effects-on-insert table-extension-triggers 1 CG-AL-M006

Description: The model added an OnAfterInsert trigger in the table extension that calls TriggerRiskAssessment() -> UpdateRiskLevel(), which validates Credit Score range (300-850). When LibrarySales.CreateCustomer inserts a new customer, Credit Score defaults to 0, which fails the validation. The model should not have added automatic risk assessment in the insert trigger, or should have guarded against unset (0) credit scores. The task asked for procedures and field validations, not automatic trigger-based assessment on insert.

Correct Pattern:
// Do NOT add OnAfterInsert trigger that calls validation logic.
// UpdateRiskLevel should handle unset credit scores gracefully:
procedure UpdateRiskLevel()
begin
    if Rec."Credit Score" = 0 then
        exit;
    if (Rec."Credit Score" < 300) or (Rec."Credit Score" > 850) then
        Error('Credit Score must be between 300 and 850.');
    case true of
        (Rec."Credit Score" >= 670) and (Rec."Credit Score" <= 850):
            Rec."Risk Level" := Rec."Risk Level"::Low;
        (Rec."Credit Score" >= 580) and (Rec."Credit Score" <= 669):
            Rec."Risk Level" := Rec."Risk Level"::Medium;
        (Rec."Credit Score" >= 500) and (Rec."Credit Score" <= 579):
            Rec."Risk Level" := Rec."Risk Level"::High;
        (Rec."Credit Score" >= 300) and (Rec."Credit Score" <= 499):
            Rec."Risk Level" := Rec."Risk Level"::Critical;
    end;
end;
Incorrect Pattern:
trigger OnAfterInsert()
begin
    TriggerRiskAssessment();
end;

procedure UpdateRiskLevel()
begin
    // validates credit score 300-850, fails when score is 0
    if (Rec."Credit Score" < 300) or (Rec."Credit Score" > 850) then
        Error('Credit Score must be between 300 and 850.');
    ...
end;