When i run any report in the test codeunits via the al test tool i get a transction error:
the error happens when in anyway when a report is run. in the current version of the code it is trigger by Report.RunRequestPage
Subtype = Test;
TestPermissions = Disabled;
EventSubscriberInstance = Manual;
InherentPermissions = X;
[Test]
[HandlerFunctions('CalculatePlanReportRequestPageHandler30D')]
[CommitBehavior(CommitBehavior::Ignore)]
[TransactionModel(TransactionModel::AutoCommit)]
procedure CreateRequestionNone()
var
ReqLine: Record "Requisition Line";
ReqWorksheet: TestPage "Req. Worksheet";
CalculatePlan: Report "Calculate Plan - Req. Wksh.";
"Req. Wksh. Template": record "Req. Wksh. Template";
"Requisition Wksh. Name": Record "Requisition Wksh. Name";
Fail: Boolean;
Succes: Boolean;
XmlParameters: Text;
begin
//[Scenario] A Requisition for an item is made
//[Given] An item for a customer a vendor and a Salesorder
PrepareSetupEnabled();
PrepareData();
//[WHEN] when a Requisition is made
//ReqWorksheet.OpenView();
// Commit();
if "Req. Wksh. Template".FindFirst() then begin
"Requisition Wksh. Name".setrange("Worksheet Template Name", "Req. Wksh. Template".Name);
if "Requisition Wksh. Name".FindFirst() then;
end;
CalculatePlan.SetTemplAndWorksheet("Req. Wksh. Template".Name, "Requisition Wksh. Name".Name);
XmlParameters := Report.RunRequestPage(Report::"Calculate Plan - Req. Wksh.");
LibraryReportDataset.RunReportAndLoad(Report::"Calculate Plan - Req. Wksh.", ReqLine, XmlParameters);
// CalculatePlan.Run;
Clear(CalculatePlan);
// ReqWorksheet.CalculatePlan.Invoke();
ReqLine.SetRange("No.", '150.160.170');
ReqLine.FindFirst();
ReqWorksheet.GoToRecord(ReqLine);
CarryOutActionMessage(ReqWorksheet);
Succes := false;
ReqLine.SetRange("No.", '150.160.170');
if ReqLine.FindSet() then
repeat
if not (ReqLine."Planning Flexibility" = ReqLine."Planning Flexibility"::None) then
Fail := true;
until ReqLine.Next() = 0;
if not Fail then
Succes := true;
//[THEN] then an a succesfull Procces should have happend;
Assert.IsTrue(Succes, 'The Requisition should have been succesfull');
end;
The eventual purpose of this codeunit is to test out calculate plan of Requisition Worksheets. Is there any solution to this problem?