Check Guidelines

This feature will check and/or correct C/AL code of selected objects in NAV. The C/AL code and the layout of pages is checked if they meet the Microsoft Guidelines requirements.
  1. Setup
  2. Coding Checks
    1. Wrong Indent
    2. Wrong IF THEN Use
    3. Wrong Line Break
    4. Missing Spaces
    5. Missing ;
    6. Unnecessary BEGIN END
    7. = TRUE
    8. = FALSE
    9. Table Name in SETRANGE
    10. Redundant Table Name
    11. Empty Lines
    12. Redundant Spaces
    13. Redundant ()
    14. FIND(-)
    15. Double Variable Names
    16. Unnecessary Properties Table
    17. TODO Comment
    18. Text in Code
    19. Wrong SETCURRENTKEY
    20. Broken Lines
    21. Missing <> in CALCDATE
    22. MARK
    23. PAGE.RUN(Integer)
    24. TextConst
  3. Layout Checks
    1. Missing Image
    2. Double Shortcut Keys
    3. Lowercase Shortcut Keys
    4. Unnecessary Properties
    5. Usage Not Existing Keys
    6. Empty Action
    7. Options in Promoted Action Categories
    8. Missing Tooltips
    9. Missing Application Areas
  4. Data Checks
    1. Key Fields are Integer, Code, Option or Date
    2. NotBlank on Key Fields
    3. Testfield on Key Fields
    4. FlowFields Not Editable
    5. No. of Option Values in Fields
    6. Primary Key in Table Relation
    7. Field Types in Relations
    8. Missing Relations
    9. Assignments
    10. Delete Relating Table
    11. Constants in Relations
    12. Lookup Page
    13. Data Caption Fields
    14. AltSearchFields
    15. Redundant MaintainSIFTIndex
    16. Field Types in Filters
    17. Data Classification
    18. Usage Category
    19. Missing SumIndexField Key
  5. Naming Checks
    1. 'tmp' in Name of Temporary Records
    2. Variable Names
    3. Object Names
    4. Field Names
    5. Reserved Names
    6. Function Names
    7. Double Captions
  6. Transport Checks
  7. Conversion Checks
    1. Application Area set without Usage Category
    2. Lefover Properties
    3. Promoted Action Properties
    4. Grid Layout
    5. RunOnClient
  8. Company Checks
  9. Caption Checks
  10. Space after Comma
  11. Check Guidelines
  12. Known comments
    1. Set Known Comments with C/AL History
    2. Import and Export Known Comments
  13. Auto Apply Guidelines
  14. Manual Apply Guidelines
  15. Perform Guidelines on Text File

Setup

Setup
Setup


There are the following general types of checks:
  • Coding Checks
  • Layout Checks
  • Data Checks
  • Naming Checks
  • Transport Checks
  • Conversion Checks
  • Company Checks
  • Missing Captions
  • Space after Comma

Zooming in to the Check Guidelines Options window for each check, you will be able to select or deselect any of the guideline checks.

Coding Checks
Coding Checks


If you would like to define a check as critical zoom into the No. of Critical Checks field a select the guideline check.

Coding Checks

This list consists of requirements the coding has to meet. Most of these requirements can be autocorrected. See section Auto Apply Guidelines for more information.
CodeNameAutocorrect
001Wrong IndentX
002Wrong IF THEN UseX
003Wrong Line BreakX
004Missing SpacesX
005Missing ;X
006Unnecessary BEGIN ENDX
007= TRUEX
008= FALSE
009Table Name in SETRANGEX
010Redundant Table NameX
011Empty LinesX
012Redundant SpacesX
013Redundant ()X
014FIND(-)
015Double Variable Names
016Unnecessary Properties Table
017TODO Comment
018Text in Code
020Wrong SETCURRENTKEY
021Broken Lines
022Missing <> in CALCDATE
023MARK
024PAGE.RUN(Integer)
025Code in OnLookup
026Comments with Brackets
027ISSERVICETIER
028TextConst

Wrong Indent

Checks if indentation is correct in code.
Comment: Wrong indent: Remove 1 space(s)

IF SalesLine."Document Type" = SalesLine."Document Type"::Order THEN BEGIN

   SalesLine.VALIDATE(Type, SalesLine.Type::Item);


   SalesLine.VALIDATE("No.", Item."No.");
END;

Should be:

IF SalesLine."Document Type" = SalesLine."Document Type"::Order THEN BEGIN
  SalesLine.VALIDATE(Type, SalesLine.Type::Item);
  SalesLine.VALIDATE("No.", Item."No.");
END;


Wrong IF THEN Use

Check on use of IF THEN (BEGIN).
Comment: 'IF' must start at new line

IF "Document Type" = "Document Type"::Order THEN
  SalesLine.SETFILTER("Quantity Shipped",'<>0')
ELSE IF "Document Type" = "Document Type"::Invoice THEN BEGIN
    SalesLine.SETRANGE("Sell-to Customer No.",xRec."Sell-to Customer No.");
    SalesLine.SETFILTER("Shipment No.",'<>%1','');
  END;

Should be:

IF "Document Type" = "Document Type"::Order THEN
  SalesLine.SETFILTER("Quantity Shipped",'<>0')
ELSE
  IF "Document Type" = "Document Type"::Invoice THEN BEGIN
    SalesLine.SETRANGE("Sell-to Customer No.",xRec."Sell-to Customer No.");
    SalesLine.SETFILTER("Shipment No.",'<>%1','');
  END;

Comment: Keep 'THEN' and 'BEGIN' together

IF xRec."Ship-to Code" <> '' THEN
  BEGIN
  GetCust("Sell-to Customer No.");
  "Tax Area Code" := Cust."Tax Area Code";
END;

Should be:

IF xRec."Ship-to Code" <> '' THEN BEGIN
  GetCust("Sell-to Customer No.");
  "Tax Area Code" := Cust."Tax Area Code";
END;

Comment: 'REPEAT' must start at new line

IF ServLedgerEntry.FINDSET THEN REPEAT
  DiscountAmount := DiscountAmount + -ServLedgerEntry."Discount Amount";
  ContractDiscAmount := ContractDiscAmount + -ServLedgerEntry."Contract Disc. Amount";
UNTIL ServLedgerEntry.NEXT = 0;

Should be:

IF ServLedgerEntry.FINDSET THEN
  REPEAT
    DiscountAmount := DiscountAmount + -ServLedgerEntry."Discount Amount";
    ContractDiscAmount := ContractDiscAmount + -ServLedgerEntry."Contract Disc. Amount";
  UNTIL ServLedgerEntry.NEXT = 0;

Comment: 'THEN' must start at new line

IF ("Account Type" = "Account Type"::"IC Partner") AND
  ("Bal. Account Type" = "Bal. Account Type"::"G/L Account") THEN BEGIN
  GLAcc.SETRANGE("No.","Bal. Account No.");
  IF GLAcc.FIND('-') THEN
    "IC Partner G/L Acc. No." := GLAcc."Default IC Partner G/L Acc. No";
END;

Should be:

IF ("Account Type" = "Account Type"::"IC Partner") AND
   ("Bal. Account Type" = "Bal. Account Type"::"G/L Account")
THEN BEGIN
  GLAcc.SETRANGE("No.","Bal. Account No.");
  IF GLAcc.FIND('-') THEN
    "IC Partner G/L Acc. No." := GLAcc."Default IC Partner G/L Acc. No";
END;

Comment: Start new line after ELSE

IF MapPoint.FIND('-') THEN
  MapMgt.MakeSelection(DATABASE::Contact,GETPOSITION)
ELSE MESSAGE(Text033);

Should be:

IF MapPoint.FIND('-') THEN
  MapMgt.MakeSelection(DATABASE::Contact,GETPOSITION)
ELSE
  MESSAGE(Text033);

Wrong Line Break

If a line is broken in two lines you should break it at the first possible break position.

Comment: Break the line at position 14

IF AskQuestion THEN BEGIN
  Question := STRSUBSTNO(
      Text031 +
      Text032,ChangedFieldName);

Should be:

IF AskQuestion THEN BEGIN
  Question :=
    STRSUBSTNO(
      Text031 +
      Text032,ChangedFieldName);

If you use a BEGIN in a CASE construction the BEGIN statement must always start at a new line.
Comment: 'BEGIN' must start at new line

CASE "Table ID" OF
  DATABASE::"G/L Account": BEGIN
    IF GLAcc.GET("No.") THEN BEGIN
      GLAcc."Global Dimension 1 Code" := NewDimValue;
      GLAcc.MODIFY(TRUE);
    END;
  END;
END;

Should be:

CASE "Table ID" OF
  DATABASE::"G/L Account":
    BEGIN
      IF GLAcc.GET("No.") THEN BEGIN
        GLAcc."Global Dimension 1 Code" := NewDimValue;
        GLAcc.MODIFY(TRUE);
      END;
    END;
END;


Missing Spaces

Checks if statements are glued together where this is not allowed.
Comment: Add space at position 27

IF "Applies-to Doc. No." <>'' THEN
  CustLedgEntry.SETRANGE("Document No.","Applies-to Doc. No.");

Should be:

IF "Applies-to Doc. No." <> '' THEN
  CustLedgEntry.SETRANGE("Document No.", "Applies-to Doc. No.");


Missing ;

Checks for open ends before an END;
Comment: Add a ';'

WITH PaymentTermsTranslation DO BEGIN
  SETRANGE("Payment Term",Code);
  DELETEALL
END;

Should be:

WITH PaymentTermsTranslation DO BEGIN
  SETRANGE("Payment Term",Code);
  DELETEALL;
END;

Unnecessary BEGIN END

Checks where a ‘BEGIN’ and ‘END’ is used where this is not necessary.
Comments: Remove 'BEGIN' and Remove ‘END'

IF "Price Includes VAT" THEN BEGIN
  IF NOT VATPostingSetup.GET("VAT Bus. Posting Gr. (Price)","VAT Prod. Posting Group") THEN
    FIELDERROR("VAT Bus. Posting Gr. (Price)");
END;

Should be:

IF "Price Includes VAT" THEN
  IF NOT VATPostingSetup.GET("VAT Bus. Posting Gr. (Price)","VAT Prod. Posting Group") THEN
    FIELDERROR("VAT Bus. Posting Gr. (Price)")


= TRUE

Checks where ‘= TRUE’ is added in an equation. This is not necessary and should be removed.
Comment: Remove '= TRUE'

IF Complete = TRUE THEN
  MESSAGE(Text003,ReportCaption1,ReportCaption2)

Should be:

IF Complete THEN
  MESSAGE(Text003,ReportCaption1,ReportCaption2)


= FALSE

Comment: Use NOT instead of '= FALSE'

IF "Related to Base Unit of Meas." = FALSE THEN
  "Qty. per Unit of Measure" := 1;

Should be:

IF NOT "Related to Base Unit of Meas." THEN
  "Qty. per Unit of Measure" := 1;


Table Name in SETRANGE

Checks if the variablename of the record is stated inside of a setrange function. All other statements (like SETFILTER, SETCURRENTKEY, etc.) are also checked.
Comment: Remove table name

SalesPrice.SETRANGE("Sales Type",SalesPrice."Sales Type"::Campaign);
SalesPrice.SETRANGE(SalesPrice."Sales Code","No.");
SalesPrice.LOCKTABLE;

Should be:

SalesPrice.SETRANGE("Sales Type",SalesPrice."Sales Type"::Campaign);
SalesPrice.SETRANGE("Sales Code","No.");
SalesPrice.LOCKTABLE;


Redundant Table Name

Checks for unnecessary record references (table names). This happens the most in reports where the name of the DataItem is not necessary in the code.
Comment: Remove table name

VAT Entry - OnPreDataItem()
"VAT Entry".COPYFILTERS(VATEntry);

Should be:

VAT Entry - OnPreDataItem()
COPYFILTERS(VATEntry);


If you use the WITH statement in your code then the table name is not necessary in the following code:

Comment: Remove table name

WITH Period DO BEGIN
  Period.SETRANGE("Period Type","Period Type"::Date);
  SETFILTER("Period Start",DateFilter);
  IF FIND('-') THEN
    EXIT("Period Start")
END;

Should be:

WITH Period DO BEGIN
  SETRANGE("Period Type","Period Type"::Date);
  SETFILTER("Period Start",DateFilter);
  IF FIND('-') THEN
    EXIT("Period Start")
END;


Empty Lines

Checks if there are two or more empty lines. And if a function starts with an empty line.
Comment: Remove empty line

IF Campaign.GET(GETFILTER("Campaign No.")) THEN
  "Campaign Description" := Campaign.Description;


IF SegHeader.GET(GETFILTER("Segment No.")) THEN
  "Segment Description" := SegHeader.Description;

Should be:

IF Campaign.GET(GETFILTER("Campaign No.")) THEN
  "Campaign Description" := Campaign.Description;

IF SegHeader.GET(GETFILTER("Segment No.")) THEN
  "Segment Description" := SegHeader.Description;


Redundant Spaces

Checks unnecessary spaces.
Comment: Remove space at position 44

IF CustLedgEntry."Amount to Apply" = 0 THEN BEGIN
  CustLedgEntry.CALCFIELDS("Remaining Amount");
  CustLedgEntry."Amount to Apply" := CustLedgEntry."Remaining Amount";
END;

Should be:

IF CustLedgEntry."Amount to Apply" = 0 THEN BEGIN
  CustLedgEntry.CALCFIELDS("Remaining Amount");
  CustLedgEntry."Amount to Apply" := CustLedgEntry."Remaining Amount";
END;


Redundant ()

Checks for unnecessary brackets.
Comment: Remove '()'

ReservEntry2 := ReservEntry;
ReservEntry2.ClearItemTrackingFields;
ReservEntry2.MODIFY();

Should be:

ReservEntry2 := ReservEntry;
ReservEntry2.ClearItemTrackingFields;
ReservEntry2.MODIFY;

Comment: Remove '(' at position 4, Remove ')' at position 26

IF (STRLEN(Parameter) = 2) THEN
  BizTalkNASStartup.RUN;

Should be:

IF STRLEN(Parameter) = 2 THEN
  BizTalkNASStartup.RUN;


FIND(-)

Checks for FIND(‘-‘) instructions which should be replaced by FINDSET, FINDFIRST or ISEMPTY. Also spots FIND(‘+’) which should be changed to FINDLAST. The FIND(‘-‘) instructions may cause performance issues on SQL based Navision.
Comment: Replace FIND('-') with 'FINDFIRST', 'FINDSET' or 'ISEMPTY'

Job.SETRANGE("Bill-to Customer No.","No.");
IF Job.FIND('-') THEN
  ERROR(Text015,TABLECAPTION,"No.",Job.TABLECAPTION);

Should be:

Job.SETRANGE("Bill-to Customer No.","No.");
IF Job.FINDFIRST THEN
  ERROR(Text015,TABLECAPTION,"No.",Job.TABLECAPTION);

Comment: Replace FIND('+') with 'FINDLAST'

CustLedgEntry.SETRANGE(Open,TRUE);
IF CustLedgEntry.FIND('+') THEN
  ERROR(Text012,FIELDCAPTION("IC Partner Code"), CustLedgEntry."IC Partner Code");

Should be:

CustLedgEntry.SETRANGE(Open,TRUE);
IF CustLedgEntry.FINDLAST THEN
  ERROR(Text012,FIELDCAPTION("IC Partner Code"), CustLedgEntry."IC Partner Code");


Double Variable Names

Checks for variable names which are used local as well as global variable.
Comment: Variable Name 'Bin' already in use as global

Variable Name Bin
Variable Name Bin


Unnecessary Properties Table

Checks for properties on fields and tables which are not needed because they are the same as the default.
Comment: Remove property: 'Yes' is default for ‘TestTableRelation’

Table Properties
Table Properties


TODO Comment

Checks for "// TODO:" in C/AL code. You can use this as a reminder.
Comment: // TODO found in code

TODO
TODO


Text in Code

Checks if there are hardcoded text messages instead of using text constants.
Comment: Replace text by text constant

ERROR('Global variable %1 is not included for test.',globalVariable);

Should be:

ERROR(Text001,globalVariable);


Wrong SETCURRENTKEY

Checks if a not existing key is used in the code.
Comment: Not Existing Key

WITH ProdOrderLine do begin
  RESET;
  SETCURRENTKEY(Status,"Completely Invoiced");
  SETRANGE(Status,Status::Finished);
  SETRANGE("Completely Invoiced",FALSE);
  EXIT(FIND('-'));
END;


Broken Lines

Checks if statement is split over multiple lines where this is not necessary.
Comment: Line does not have to be broken

IF WhseJnlLine.FINDFIRST THEN
  ERROR(
    Text007,
    FIELDCAPTION("Adjustment Bin Code"));

Should be:

IF WhseJnlLine.FINDFIRST THEN
  ERROR(Text007,FIELDCAPTION("Adjustment Bin Code"));


Missing <> in CALCDATE

Checks if the DateExpression in a CALCDATE call is entered with < > delimiters surrounding it.
Comment: Add '<>' to CALCDATE

AllowedPostingDate := CALCDATE('+1D',AllowedPostingDate);

Should be:

AllowedPostingDate := CALCDATE('<+1D>',AllowedPostingDate);


MARK

Identifies any call to MARK and suggests to use a temporary record instead.
Comment: Use temporary record instead of marking

PAGE.RUN(Integer)

Checks if an integer is used in commands like PAGE.RUN(…), REPORT.RUN(...), etc.
Comment: Replace integer with OBJECT::<object name>"

PAGE.RUN(1);

Should be:

PAGE.RUN(FORM::"Company Information");


TextConst

  • Checks if the string parameters (%1, %2 etc.) in the caption of textconst are all the same
  • Check if the string parameters (%1, %2 etc.) is missing in a TextConst
  • Check if all captions in a TextConst ends with the same punctuation (dot, question mark)
  • Checks if exclamation mark is used (using an exclamation mark is not recommended)

Layout Checks

CodeName
001Missing Image
003Double Shortcut Keys
004Lowercase Shortcut Keys
005Unnecessary Properties
006Usage Not Existing Keys
007Empty Action
008Options in Promoted Action Categories
009Missing Tooltips
009Missing Application Areas

Missing Image

Checks if actions on pages have images.
Comment: add an image

Missing Image
Missing Image


Double Shortcut Keys

Checks if two actions on a page uses the sames shortcut key or if they conflict with the shortcut keys of NAV.
Comment: Shortcut key Ctrl+F7 already in use

Double Shortcutkeys
Double Shortcutkeys


Lowercase Shortcut Keys

Checks if shortcut keys are defined with uppercase characters.
Comment: Change shortcut key to uppercase

ShortcutKey with Lowercase p
ShortcutKey with Lowercase p


Unnecessary Properties

Check for default properties in page controls and actions. These properties should be emptied.

Property Value 'Card' is the Default Value
Property Value 'Card' is the Default Value


Usage Not Existing Keys

Checks if in a SourceTableView, SubPageView, RunPageView etc. non existing key is used.
Comment: Not existing key

Not Existing Key
Not Existing Key


Empty Action

Checks if there is C/AL code written behind an action. Without C/AL the action will not be visible.

Options in Promoted Action Categories

Checks if the promoted actions and categories matches.
Comment: No. of options not the same for 'ENU'
Comment: Promoted category 'Approve' not is use
Comment: No caption specified for 'Category 6'

Missing Tooltips

Checks if all your actions on pages have tooltips.
Comment: This action has no tooltip

Missing Application Areas

Checks if all your pages en controls have application areas.
Comment: Add application Area

Data Checks

CodeName
001Key Fields are Integer, Code, Option or Date
002NotBlank on Key Fields
003Testfield on Key Fields
004Flowfields Not Editable
005No. of Option Values in Fields
006Primary Key in Table Relation
007Field Types in Relations
008Missing Relations
009Assignments
010Delete Relating Table
011Constants in Relations
012Transferfields
013Lookup Page
014Data Caption Fields
015AltSearchFields
016Redundant MaintainSIFTIndex
017Field Types in Filters
018Data Classification
019Usage Category
020Missing SumIndexField Key

Key Fields are Integer, Code, Option or Date

Checks if keyfields are of type:
  • Integer
  • Code
  • Option
  • Date

Comment: Try to avoid 'Decimal' in primary key.

Decimal as Primary Key
Decimal as Primary Key


NotBlank on Key Fields

Checks if property of keyfield is set to NotBlank. This check is only done on tables with one primary keyfield of type code.
Comment: Add NotBlank property

Testfield on Key Fields

Checks if TESTFIELD function is set on key fields in the OnInsert trigger of the table. This check is only done on tables with one primary key field of type code.
Comment: Add TESTFIELD(Code);

FlowFields Not Editable

Checks if the Editable property of flowfields is set to No.
Comment: Make not editable

No. of Option Values in Fields

Checks if an option in the OptionCaptionML is missing.
Comment: No. of options not the same for Language 'ENU'

Primary Key in Table Relation

Checks if in a table relation the primary key field is used. If it is a relation to a table with a single primary key this is not needed and should be removed.
Comment: Remove Primary Key Field 'No.' from TableRelation

Table Relation with Field
Table Relation with Field


Field Types in Relations

Checks fields if related fields in table relation and FlowField CalcFormulas have same data type.
Comment: The related field in table 'Item' is 'Text175'
The Description field on Item table has data type Text175, while the BOM Description field on the BOM Component has data type Text50.

Field is to Small
Field is to Small


Missing Relations

Check is a table relation is present when in C/AL code a field is filled with the primary keys field of another table.
Comment: Relation is missing

Missing Table Relation
Missing Table Relation


Assignments

Checks if an overflow can occur when fields are assigned in C/AL code.
Comment: This assignment can cause an overflow. Text50 := Text175

Overflow
Overflow


Delete Relating Table

Checks if in the delete trigger of a table all related sub-tables are deleted.
Comment: Related records in table Item Amount are not deleted

Constants in Relations

Checks if in a string is used in a table relation.
Comment: Do not use a string in a table relation

String Used in a Table Relation
String Used in a Table Relation


Lookup Page

  • Checks if lookup and drilldown page has the same table no. as the table itself
  • Checks if lookup and drilldown pages are list pages

Comment: Wrong Source table

Wrong Lookup and DrillDown Page
Wrong Lookup and DrillDown Page


Comment: Not a list page

Not a List Page
Not a List Page


Data Caption Fields

Checks if the data caption fields are specified on a table. Data Caption Fields are the fields shown when you do the look up.
Comment: Add data caption fields

Missing Data Caption Fields
Missing Data Caption Fields


AltSearchFields

Checks if AltSearchField is present for master data tables (only enabled in classic client). You get a warning if AltSearchField functionality is used
Comment: Remove AltSearchField property

Redundant MaintainSIFTIndex

Check that MaintainsSIFTIndex is disabled for the primary key if SumIndexFields are present.
Comment: Disable MaintainSIFTIndex for this primary key

MaintainSIFTIndex
MaintainSIFTIndex


Field Types in Filters

Checks if the fields that you use in link properties such as SubPageLink and LinksFields have same data type.
Comment: Fields are not the same Code20 <> Code10

Field Types in Filters
Field Types in Filters


Data Classification

Checks if your table field have a data classification specified.
Comment: Data to be classified

Usage Category

Checks if your card and list pages have a Usage Category specified.
Comment: Add UsageCategory property

Missing SumIndexField Key

Checks if a matching key with a SumIndexField is present for your SUM and AVERAGE flowfields.
Comment: No key with SumIndexField Amount and all the filters found in table G/L Entry

Naming Checks

This feature checks the correct naming
CodeName
001'tmp' in Name of Temporary Records
002Variable Names
003Object Names
004Field Names
005Reserved Names
006Function Names
007Double Captions

'tmp' in Name of Temporary Records

Checks if ‘tmp’ is in the name of a temporary record. A warning will be given if a record variable has ‘tmp’ in its name and is not a temporary record. Other way around when a temporary record has no ‘tmp’ in its name also a warning appears. The following name parts will be seen as temporary:
  • Tmp
  • Temp
  • Buf
  • Buffer

Comment: Add 'tmp', 'temp' or 'buffer' to variable name
Comment: Remove 'Temp' from variable name

Variable Names

Variable names must start with capital letter. The first and second letter of the name can be lowercase because of the common use of prefixes.
Comment: Start a variable name with a capital
  • dimensionValue: Not allowed
  • pCustomer: Allowed

Also spaces in the variable name will be noticed.
Comment: Remove space from variable name

Object Names

Object names have the same check as variable names except for spaces. Double spaces however are noticed.

Field Names

Same checks as Object Names.

Reserved Names

Checks if variable-, field- and function names are conflicting with existing functions and commands.
Comment: 'CopyFilters' is a reserved command.

Function Names

Checks if a function name contains spaces.
Comment: Remove space from function name

Double Captions

Checks if the captions of table fields are conflicting.

Transport Checks

Transport checks are only performed when the Check Guidelines is executed either from projects or transports.
CodeName
001Project Tag Present
002Objects in License
003Indirect Permissions

Conversion Checks

Conversion checks are enabled if you choose database type conversion. A database that is used to convert your objects to AL format.
CodeName
001Application Area set without Usage Category
002Lefover Properties
003Promoted Action Properties
004Grid Layout
005RunOnClient

Application Area set without Usage Category

Checks if a Usage Category is missing in one of your objects.
Comment: Application Area set Without Usage Category

Lefover Properties

Checks if there are properties in your objects that are not valid in AL objects. You can choose to remove them or to leave them in your objects and let a converter action remove them when you convert your objects with the C/AL to AL Converter. More info: C/AL to AL Converters.
Comment: TestTableRelation not supported

Promoted Action Properties

Checks if one of the properties PromotedCategory, PromotedIsBig or PromotedOnly is set without the Promoted property.
Comment: PromotedIsBig can only be set for promoted actions

Grid Layout

Checks if a grid layout matches the layout.
Comment: GridLayout only supported on Grids

RunOnClient

Checks if there are dotnet variables declared with RunOnClient.
Comment: Remove RunOnClient property

Company Checks

You can add guideline checks that are specific for your company by subscribing to three publisher functions.
Here is an example how you can check if all VAR parameters that starts with Tmp are temporary:

InitializeCompanyChecks:

Sender.AddCompanyCheck(900, TxtCheckTmpParameterVariable, TRUE);


AnalyseObject:

IF TmpProcedure.FindSetWithParentEntryNo(TmpObject."Entry No.") THEN
  REPEAT
    IF TmpVariable.FindSetWithParentEntryNoType(TmpProcedure."Entry No.", TmpVariable.Type::Parameter) THEN
      REPEAT
        IF TmpVariable."Is Var" AND NOT TmpVariable."Is Temporary" AND (DELSTR(TmpVariable.Name, 4) = 'Tmp') THEN
          Sender.AddCompanyComment(Comment, 900, TxtMakeVariableTemporary, TmpVariable."Line No.", TmpVariable.Identifier);
       UNTIL TmpVariable.NEXT = 0;
  UNTIL TmpProcedure.NEXT = 0;


CorrectCompanyComments:

IF TmpProcedure.FindSetWithParentEntryNo(TmpObject."Entry No.") THEN
  REPEAT
    IF TmpVariable.FindSetWithParentEntryNoType(TmpProcedure."Entry No.", TmpVariable.Type::Parameter) THEN
      REPEAT
        IF TmpVariable."Is Var" AND NOT TmpVariable."Is Temporary" AND (DELSTR(TmpVariable.Name, 4) = 'Tmp') THEN BEGIN

          TmpVariable."Is Temporary" := TRUE;
          TmpVariable.Modification := TmpVariable.Modification::Update;
          TmpVariable.MODIFY;

          NoOfCommentsCorrected += 1;
        END;
      UNTIL TmpVariable.NEXT = 0;
  UNTIL TmpProcedure.NEXT = 0;


Caption Checks

Checks all objects for missing captions and redundant spaces in captions. To enable this feature select Check Missing Captions in the Object Manager Setup window. Caption checks will only be executed in the range of languages the user has defined in the setup.

Setup
Setup


Checking the captions typically can show the following comments:
  • Add caption to object - The object checked does not have any captions defined for.
  • Add caption - The field or control checked does not have any captions defined for.
  • Add <language> caption - The field or control checked does not have a caption defined for the designated language.
  • Remove space from caption - The caption contains a redundant space.

Use the Update Captions window to view the individual check results and update them.

Update Captions
Update Captions


Update Captions
Update Captions


If a translation for a specific language has been defined as a translation rule you can insert a missing caption for that language using the Apply Guidelines to Selection feature on the Code window. For more info see section Translation Rules.

Auto Apply Missing Captions
Auto Apply Missing Captions


Missing Caption Added
Missing Caption Added


If a lot of captions are missing you can add those with the translation tool. For more info see chapter Translation Tool.

Space after Comma

The guidelines of NAV says that you cannot put a space after a comma. Many developers like to place there a comma anyway. In the setup you can choose which method the Object Manager has to check.

Setup
Setup


If you choose the option Mandatory your code have to look like this:

IF NOT PrinterSelection.GET(USERID, ReportID) THEN
  IF NOT PrinterSelection.GET('', ReportID) THEN
    IF NOT PrinterSelection.GET(USERID, 0) THEN
      IF PrinterSelection.GET('', 0) THEN;


If you choose the Prohibited setting your code has to look like this:

IF NOT PrinterSelection.GET(USERID,ReportID) THEN
  IF NOT PrinterSelection.GET('',ReportID) THEN
    IF NOT PrinterSelection.GET(USERID,0) THEN
      IF PrinterSelection.GET('',0) THEN;


It is also possible to leave this option blank. The Object Manager will not check for spaces after comma.

Check Guidelines

The Check Guidelines tool can be found in menu Analyzing Tools > Check Guidelines.

Check Guidelines
Check Guidelines


Add the objects you want to check. If you have a range of objects you want to add you also can use the function Add Objects.

Add Objects
Add Objects


Enter the filters. The objects will be added to the worksheet. To check the object(s) start function Check.

Check
Check


When finished all criteria you selected in the setup is checked. The No. of Comments per Object can also be seen in the lines.

No. of Comments per Object
No. of Comments per Object


If you drill down on the quanties you see the guidelines comments and the corresponding C/AL Code.

Guideline Comments
Guideline Comments


Function Name can also be shown in the View Check Guidelines, make sure to add the corresponding column in order to see the Function Name values. By using the Code button in this page on the selected object you can go to the C/AL where the Check Guidelines tool found the comments. If you want to loop through all comments you can use the function buttons Previous and Next.

Code Editor
Code Editor


Known comments

You can set a comment as Known Comment if you don’t want to solve the comment. This is often done when the comments apply to standard NAV objects. The benefit of using the know comment option is that you can easily see a new comment because this comment is not set to ‘known’.

Known Comments
Known Comments


Set Known Comments with C/AL History

With this function you can set all comments to known that were already present on a certain moment. This can be useful when you work on a particular project for a week and you want to know which comments were newly created in this week.
Set the date and press OK. All comments that were already in the objects at April the 18th will be set the known. The comments that will remain as new are the comments that are newly created since April the 18st.

New Comments Since Last Week
New Comments Since Last Week


Import and Export Known Comments

With this function you can import and export all your known comments from or to other databases. So you don’t have to set them again in a new database.


Auto Apply Guidelines

You have the ability to let the Object Manager correct some of the check coding guidelines comments. Beware that automatic changing by the tool isn’t possible for all guideline checks. Only auto apply guidelines in a development environment and test the changes before transporting your objects to the production environment. It is possible to apply the guidelines to a selection of code. All comments of the objects. Or a selection of objects.

Manual Apply Guidelines

There are also coding guideline checks that cannot be auto applied. E.g. the FIND(-) check can be replaced with more possibilities so this can only be done manually. The fastest way to do this is directly in the code page.

Use the Editor to Correct Comments
Use the Editor to Correct Comments


Here it is possible to edit a line of code and press the save button. The objects will be saved and the guidelines will be rechecked and the comment will be deleted.

Layout checks can be best solved in the Object Designer. To open the object in design mode you can press Design. The Object Designer will open the selected object in design modus. Also Data and Naming checks have to be done directly in the object itself or by modifying the results in the Editor page.

Perform Guidelines on Text File

See chapter File Function - Check Guidelines for more info.