Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Indent string field based on indentation (BOM)

(0) ShareShare
ReportReport
Posted on by 130

Hi All,

I am trying to create an indented BOM in BC. The closest I get is when I show BOM from assembly item, giving an image like the below. Ideally - I want the "No." field name to be indented based on indentation level value 

My AL code is below as well, as a page extension for BOM STRUCTURE....however it doesn't seem to do anything on the page...what am i missing?

pastedimage1683678756628v1.png

    trigger OnOpenPage()
    var
        levelOneIndent: Text[20];
        levelTwoIndent: Text[20];
    begin
        levelOneIndent := '     ';
        levelTwoIndent := '          ';
        repeat
            if rec.Indentation = 1 then
                rec."No." := levelOneIndent   rec."No.";
            if rec.Indentation = 2 then
                rec."No." := levelTwoIndent   rec."No.";
            rec.Modify()
        until rec.Next() = 0;
    end;

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    RE: Indent string field based on indentation (BOM)

    Hi, I tested copying and pasting directly to Excel, same problem. So unfortunately, as Govinda mentioned, this can only be done manually.

    pastedimage1683854308008v1.png

    pastedimage1683854314039v2.png

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: Indent string field based on indentation (BOM)

    I believe when you export the data to Excel, you won't be able to keep the same indentation as in BC. You'll need to manually select the columns that contain the indentation level and format them to be indented in Excel. 

    pastedimage1683815000615v1.png

  • SammySevens Profile Picture
    SammySevens 130 on at
    RE: Indent string field based on indentation (BOM)

    Thank you all, and Zhu thank you for the example, now I understand it. 

    My only question is how do I persist this indentation when exporting to excel? It seems like when I export to an excel spreadsheet, the indentation is gone. Please see below (based on existing replenishment system)

    Thank you

    pastedimage1683772554646v1.png

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    RE: Indent string field based on indentation (BOM)

    Hi, there is a very good example in the post below, hopefully it will give you some hints.

    https://businesscentralgeek.com/tree-view-property-business-central

    Thanks

    ZHU

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: Indent string field based on indentation (BOM)

    Do you mean you want to use your "No." field as an indentation field like Replenishment field in your picture? if not then simply adding the field should get indented with all the other fields.. you don't have to add extra empty space.. also why don't you try the OnAfterGetCurrRecord trigger? and instead of using Indentation, you can look at the "Low-Level Code" field..

  • Robert Jolliffe Profile Picture
    Robert Jolliffe 859 on at
    RE: Indent string field based on indentation (BOM)

    If you look at the Cost Shares page (under an Item | Navigate | BOM | Cost Shares) that is a good example of an indented BOM structure.

  • KasparsSemjonovs Profile Picture
    KasparsSemjonovs 3,962 Super User 2024 Season 2 on at
    RE: Indent string field based on indentation (BOM)

    As the Replenishment System is already field where indendation works, I would advice just to Copy/compare that part with Your field No.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans