visual-studio-codereferencenavisiondynamics-business-centraldynamics-al

How to find all references (or occurrences) of a certain field in the code of a Business Central .app


I'm working with an imported .app, it's open source (but readonly) so in .alpackages folder I can click in the .app file in Visual Studio Code and navigate through all its code files (tables, extensions, codeunits...).

Let's say I'm working with a certain field of a table extension of the .app, and I need to know how this file is used in the .app, so I'd like to find all references of this field in the code of the whole .app. This task is easily done in other IDEs like Eclipse or Visual Studio (F12 shortcuts), but I can't find a way to get it with Visual Studio Code.

Here is an example, I need to find all references to the field "LSC Explode BOM in Statement Post", there may be about 10 references or less in the code of the .app. It would also help me if I can't search it by text (not through hard code references) if it is possible

The field in the .app is a normal Boolean field defined on a tableextension as usually done

tableextension 10000726 "LSC Item" extends Item
{
    fields
    {

        // Other fields...

        field(99001544; "LSC Explode BOM in Statem Post"; Boolean)
        {
            Caption = 'Explode BOM in Statem. Posting';
        }

I have some (working) code making reference to that field in my own project, and by selecting the field and pressing F12 and Shift+F12 I can only find references in my own code files, but not in the .app files, i.e. here:

if ((Item."LSC Explode BOM in Statem Post") and (Item."LSC BOM Type" <> Item."LSC BOM Type"::Prepack)) or
                   ((Item."LSC Fuel Item") and (TransSalesEntry."Variant Code" <> ''))
                then begin
                    BOMPostingBuffer[1]."Document No." := DocNumber;

Or there's maybe a way or an extension for opening all files of an .app and search by text in all opened files? It sounds heavy, but I don't care if the search takes hours to finish, it's better than manually search :(

I hope I have explained it well, if you need more info just ask


Solution

  • I'm glad to tell you it is possible to unzip the .package (i.e. with 7-zip), get all code files and then open it in your favorite IDE, and make any search by name. Steps to follow:

    1. Unzip the package
    2. You go to the folder C:/.../your_unzip_package_path/src/Base
    3. In my case, I needed to replace '%2520' in file names by spaces by using this command in PowerShell: Get-ChildItem -Recurse | Rename-Item -NewName { $_.Name -replace '%2520',' ' } (here you may get some errors due to files that doesn't need to replace anything on its name)
    4. Open the /Base folder i.e. with Visual Studio Code
    5. Make any search by name in the whole project: Ctrl+Shift+F with any code file selected

    I hope it help to you all AL/Navision/Business Central/LS Retail developers :D