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;
}