Skip to main content

Notifications

Announcements

No record found.

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

Getting Multiples lines data into Standard dialogue type page from a table

Posted on by 17
Hello experts, I have a requirement I am developing code that goes like this.
I have an action button in the Purchase order lines with part names as Quality.
1. 
When the user selects an Item in the purchase line and clicks on the quality button it opens up a popup window type of Standard dialogue
2. Here item has a custom field named quality code which basically stores No series.
3. The popup window with the same data that is selected in the purchase line as shown in Figure f2. 
4. now I need a requirement that I have a card page that has a part (subforum) as shown in Figure 3.
5. Here my requirement is when I hit the quality button after selecting an item it has a field named /number_buffer/, and item no and item description filled I need take the /number_buffer/ from the quality box page table and match it with /No./ (typically both stores same kind of value) if they match insert into dialog box page which has same fields if 3 records in subforum part it should insert 3 lines into the dialogue box.
6. I have written some code but getting one record as shown in Fig 3 even though that item has 2 lines in subform page.
I have shared the code. 
please suggest me the proper way to achieve this. 
//

fig 2
 
//
fig 3 
//

 
pageextension 71516710 myext extends /Purchase Order Subform/
{
    actions
    {
        addafter(BlanketOrder)
        {
            action(Quality)
            {
                ApplicationArea = All;
                Caption = 'Quality';
                Image = Action;
                ToolTip = 'Open the quality dialog box for the selected item';
                trigger OnAction()
                var
                    QualityDialog: Page QualityDialog;
                    QualityCode: Record QualityCodeTable;
                    Item: Record Item;
                    PurchaseLine: Record /Purchase Line/;
                    IsHandled: Boolean;
                    MyCodeunit: Codeunit MyCodeunit;
                begin
                    CurrPage.SetSelectionFilter(PurchaseLine);
                    if PurchaseLine.FindSet() then begin
                        repeat
                            if (PurchaseLine.Type = PurchaseLine.Type::Item) or (PurchaseLine.Type = PurchaseLine.Type::/Fixed Asset/) then begin
                                Item.Get(PurchaseLine./No./);
                                if Item./Quality Applicable/ then begin
                                    if Item./Quality code/ <> '' then begin
                                        QualityCode.Get(Item./Quality code/);
                                        MyProcedure(PurchaseLine, QualityDialog);
                                    end else
                                        Error('The item %1 does not have a quality code assigned.', Item./No./);
                                end else
                                    Error('The item %1 is not quality applicable.', Item./No./);
                            end else
                                Error('The line type %1 is not supported for quality.', PurchaseLine.Type);
                        until PurchaseLine.Next() = 0;
                    end else
                        Error('No purchase line is selected.');
                end;
            }
        }
    }
 
    var
        PurchaseHeader: Record /Purchase Header/;
 
    local procedure MyProcedure(var Rec: Record /Purchase Line/; var DialogBox: Page QualityDialog)
    var
        MainTable: Record QualityCodeTable;
        PartTable: Record QualityParamater;
        QualityParamaterSubform: Record QualityParamaterSubform;
        BufferTable: Record QualityCodeTabletestdialoug;
        TempBufferTable: Record QualityCodeTabletestdialoug temporary;
        Item: Record Item;
    begin
        Item.SetRange(/No./, Rec./No./);
        if Item.FindFirst() then begin
            MainTable.SetRange(Number, Item./Quality Code/);
            if MainTable.FindSet() then begin
                repeat
                    BufferTable.SetRange(Number_buffer, MainTable.Number);
                    BufferTable.SetRange(/Line No/, QualityParamaterSubform./Line No/);
                    if BufferTable.FindFirst() then begin
                        BufferTable./Item No./ := MainTable./Item No./;
                        BufferTable./Item Description/ := MainTable./Item Description/;
                        BufferTable.Modify();
                    end else begin
                        BufferTable.Init();
                        BufferTable./Number_buffer/ := MainTable.Number;
                        BufferTable./Line No/ := QualityParamaterSubform./Line No/;
                        BufferTable./Item No./ := MainTable./Item No./;
                        BufferTable./Item Description/ := MainTable./Item Description/;
                        BufferTable.Insert();
                    end;
 
                    TempBufferTable := BufferTable;
                    TempBufferTable.Insert();
 
                    // Move this line outside the loop to avoid unnecessary database operations.
                    DialogBox.SetTableView(TempBufferTable);
 
                until MainTable.Next() = 0;
 
                // Run the dialog box after all records have been processed.
                DialogBox.Run();
            end;
        end;
    end;
}
Categories:
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    Kamal Khakhkhar 303 on at
    Getting Multiples lines data into Standard dialogue type page from a table
    Hii There,
    for add multiple new line in page there is property already available in page default property as MultipleNewLines=true; by which you can add multiple new lines.
    but there is a restriction that you can not add this property by using PageExtension.
     
    its not allowed in page extension. so you can try by creating new page just like the base as in new version 23 wave 2 .
    you can use namespace to create/Modify your base page requirement as per your requirement. but Its introduced recently so need more time to understand other factors also .
     
    Experts can give more accurate answer for this.
     
    Thank You,
    Kamal Khakhkhar

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans