Object Manager

Analyzing Tools

The chapters below describe the feature set of Analyzing Tools page.

 

 

Where Used Objects


With this tool, you can check where objects, fields, triggers, etc. are used. It is also possible to see if an object is unused and if it is called without validation.

 

You can search on the following type of objects:

  • Object

  • Trigger

  • Key

  • Sum Index Field

  • Field

  • Global Function

  • Local Function

  • Global Variable

  • Local Variable

  • Parameter

  • Return Value

  • Global Publisher

  • Local Publisher

  • Global Subscriber

  • Local Subscriber

  • Event

Setup

Use the “Update Where Used” field on Object Manager Setup window to

  1. Confirm – Let Object Manager ask you whether or not you want the “Where Used Objects” be updated

  2. Always – Let this process be run automatically each time you open the “Where Used Object Card”

  3. Never – Skip this process

In order to use the Where Used functionality Object Manager needs to update the Where Used Objects. This is done in three steps:

  1. Updating “C/AL History”

  2. Updating “Where Used Objects”. The C/AL code is analyzed and every item that can be used somewhere is saved

  3. Updating “Where Used In”. The C/AL code is analyzed and every entry where an item, found in step 2, is used in is saved

     

    For each object that changes these three steps will be executed again. So your Where Used Objects will always be up to date. This is a time-consuming process. If you cancel the updating process halfway, it will continue, the next time you open the Where Used window, from that point on.

Find out Where an Object is used

When everything is updated the Where Used Object Card opens.

Some lines are colored:
Red – Used but not active
Green – Not used
Grey – Not active
Blue – Global function that is only used local

To find out where an element is used you press the Where Used button. For example the Insert trigger of the Cust. Ledger Entry table. The Where Used In window opens. Here you see the different lines of code that are calling the Insert trigger.

 

Once you have selected a line press Code to get a view on the full C/Al code context with the specific line where the trigger is used highlighted.

 

The “Temporary Record” column in the “Where Used In” window indicates that the C/AL statement uses a temporary record.

Relations

On tab relations, you can see the relations between tables. It is also possible to see which objects are used in the object and in which objects the object is used.

Examples

Find out where the Table “Finance Charge Terms” is used.

 

Find out where codeunit Sales Post is called.

 

Find out where the field Ship-to Code of table Sales Header is filled without validation.

 

Find out where the SIF Field Credit Amount of the table G/L Entry is used.

Find out how many unused variables codeunit Payment Tolerance Management has.

 

What Used In

If you want to see what is used in a line of code you can use the function What Used In.

 

Delete Where Used Object Lines

It is possible to delete unused “Where Used Object Lines”. It will also delete the entity from the object itself.
For example we have made a field 50.000 in the Customer table but is not used anywhere. We can delete that “Where Used Object Line”. The content of the field will be deleted and the field will be deleted from the table.

MenuSuite Viewer from Where Used

When objects are used in MenuSuites you can see with the function Show in MenuSuite Viewer where it is used.

Enable or Disable Keys and Fields

Using the Enabled field on the lines of the Where Used Object Card, you can enable of disable keys and fields. This will not work for primary keys, fields containing data, fields being part of an active key, and any other type of lines, like Trigger, Global Function, etc.

 

Search String in C/AL Code


With this tool you can search for a string in objects. In the Search for you can enter the statement, you want to search for.

 

Search in History
The function will not only search for the string in the actual objects but also in the former versions.
Press Search.

 

The No. of Times column is filled and it is possible to zoom in to the C/AL where the statement is used.

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.

 

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.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.

 

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:

Comment: Keep ‘THEN’ and ‘BEGIN’ together

Should be:

Comment: ‘REPEAT’ must start at new line

Should be:

Comment: ‘THEN’ must start at new line

Should be:

Comment: Start new line after ELSE

Should be:

 

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

Should be:
bc. IF AskQuestion THEN BEGIN Question := STRSUBSTNO;

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

Should be:

 

Missing Spaces


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

Should be:

Missing ;


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

Should be:

 

Unnecessary BEGIN END


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

Should be:

 

= TRUE


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

Should be:

= FALSE


Comment: Use NOT instead of ‘= FALSE’

Should be:

 

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

Should be:

 

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

Should be:

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

Comment: Remove table name

Should be:

Empty Lines


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

Should be:

Redundant Spaces


Checks unnecessary spaces.
Comment: Remove space at position 44

Should be:

Redundant ()


Checks for unnecessary brackets.
Comment: Remove ‘()’

Should be:

Comment: Remove ‘(’ at position 4, Remove ‘)’ at position 26

Should be:

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’

Should be:

Comment: Replace FIND with ‘FINDLAST’

Should be:

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.

 

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’

 

TODO Comment


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

 

Text in Code


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

Should be:

 

Wrong SETCURRENTKEY


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

 

Broken Lines


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

Should be:

 

Missing in CALCDATE


_Checks if the DateExpression in a CALCDATE call is entered with < > delimiters surrounding it.
Comment: Add ‘<>’ to CALCDATE_

Should be:

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::“

Should be:

 

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)

IDYN 2024