Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -1225,11 +1225,14 @@ page 508 "Blanket Sales Order Subform"
end;

local procedure UpdateTypeText()
var
RecRef: RecordRef;
begin
if not TypeAsTextFieldVisible then
exit;

TypeAsText := Rec.FormatType();
RecRef.GetTable(Rec);
TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));
end;

/// <summary>
Expand Down
30 changes: 30 additions & 0 deletions src/Layers/CH/Tests/Misc/OptionLookupBufferTest.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,36 @@
until TempOptionLookupBuffer.Next() = 0;
end;

[Test]
[Scope('OnPrem')]
procedure BlanketSalesOrderSupportsLongLineTypeCaption()
var
Customer: Record Customer;
SalesLine: Record "Sales Line";
OptionLookupBufferTest: Codeunit "Option Lookup Buffer Test";
BlanketSalesOrder: TestPage "Blanket Sales Order";
LineTypeCaption: Text[30];
begin
// [SCENARIO 644921] A line type caption longer than 20 characters can be selected on a blanket sales order
Initialize();

// [GIVEN] A custom line type with a long caption and a blanket sales order
BindSubscription(OptionLookupBufferTest);
LineTypeCaption := Format(SalesLine.Type::Test_Custom1);
Assert.IsTrue(StrLen(LineTypeCaption) > 20, 'The test line type caption must be longer than 20 characters.');
LibrarySales.CreateCustomer(Customer);
BlanketSalesOrder.OpenNew();
BlanketSalesOrder."Sell-to Customer Name".SetValue(Customer.Name);

// [WHEN] Selecting the custom line type
BlanketSalesOrder.SalesLines.First();
BlanketSalesOrder.SalesLines.FilteredTypeField.SetValue(LineTypeCaption);

// [THEN] The complete caption is displayed
BlanketSalesOrder.SalesLines.FilteredTypeField.AssertEquals(LineTypeCaption);
BlanketSalesOrder.Close();
end;

[Test]
[Scope('OnPrem')]
procedure SalesInvoiceSubtypeAutoComplete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,11 +1221,14 @@ page 508 "Blanket Sales Order Subform"
end;

local procedure UpdateTypeText()
var
RecRef: RecordRef;
begin
if not TypeAsTextFieldVisible then
exit;

TypeAsText := Rec.FormatType();
RecRef.GetTable(Rec);
TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1228,11 +1228,14 @@ page 508 "Blanket Sales Order Subform"
end;

local procedure UpdateTypeText()
var
RecRef: RecordRef;
begin
if not TypeAsTextFieldVisible then
exit;

TypeAsText := Rec.FormatType();
RecRef.GetTable(Rec);
TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,11 +1217,14 @@ page 508 "Blanket Sales Order Subform"
end;

local procedure UpdateTypeText()
var
RecRef: RecordRef;
begin
if not TypeAsTextFieldVisible then
exit;

TypeAsText := Rec.FormatType();
RecRef.GetTable(Rec);
TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ enumextension 134645 "Mock Sales Line Type - Custom" extends "Sales Line Type"
{
value(134645; Test_Custom1)
{
Caption = 'Test_Custom1';
Caption = 'Test Long Line Type Caption', Locked = true;
}
value(134647; Test_Custom2)
{
Expand Down
30 changes: 30 additions & 0 deletions src/Layers/W1/Tests/Misc/OptionLookupBufferTest.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,36 @@ codeunit 134645 "Option Lookup Buffer Test"
until TempOptionLookupBuffer.Next() = 0;
end;

[Test]
[Scope('OnPrem')]
procedure BlanketSalesOrderSupportsLongLineTypeCaption()
var
Customer: Record Customer;
SalesLine: Record "Sales Line";
OptionLookupBufferTest: Codeunit "Option Lookup Buffer Test";
BlanketSalesOrder: TestPage "Blanket Sales Order";
LineTypeCaption: Text[30];
begin
// [SCENARIO 644921] A line type caption longer than 20 characters can be selected on a blanket sales order
Initialize();

// [GIVEN] A custom line type with a long caption and a blanket sales order
BindSubscription(OptionLookupBufferTest);
LineTypeCaption := Format(SalesLine.Type::Test_Custom1);
Assert.IsTrue(StrLen(LineTypeCaption) > 20, 'The test line type caption must be longer than 20 characters.');
LibrarySales.CreateCustomer(Customer);
BlanketSalesOrder.OpenNew();
BlanketSalesOrder."Sell-to Customer Name".SetValue(Customer.Name);

// [WHEN] Selecting the custom line type
BlanketSalesOrder.SalesLines.First();
BlanketSalesOrder.SalesLines.FilteredTypeField.SetValue(LineTypeCaption);

// [THEN] The complete caption is displayed
BlanketSalesOrder.SalesLines.FilteredTypeField.AssertEquals(LineTypeCaption);
BlanketSalesOrder.Close();
end;

[Test]
[Scope('OnPrem')]
procedure SalesInvoiceSubtypeAutoComplete()
Expand Down