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.
[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);
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;
[RequestPageHandler]
[TransactionModel(TransactionModel::AutoCommit)]
procedure CalculatePlanReportRequestPageHandler30D(var CalculatePlan: TestRequestPage /Calculate Plan - Req. Wksh./);
begin
CalculatePlan.StartingDate.SetValue(workdate());
CalculatePlan.EndingDate.SetValue(CalcDate('+30D', WorkDate()));
CalculatePlan.OK().Invoke();
end;
The eventual purpose of this codeunit is to test out calculate plan of Requisition Worksheets.
Is there any solution to this problem?