'al/createPackage' failed with error: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'
Describe the bug When compiling an Al project, I get an unclear error when adding a codeunit :
'al/createPackage' failed with error: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'
Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible
When deleting the codeunit, I can continue compiling
error:
ystem.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.DiagnosticFormatter.Format(Diagnostic diagnostic, IFormatProvider formatter) in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Diagnostics\DiagnosticFormatter.cs:line 57
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.ReportErrors(IEnumerable1 diagnostics, CompilerTextWriter consoleOutput, ErrorLogger errorLogger) in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 258
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCoreImpl(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, Compilation compilation, AnalyzerDriver analyzerDriver, IEnumerable1 analyzerExceptionDiagnostics, IEnumerable1 additionalTextFiles, CancellationToken cancellationToken) in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 524
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 490
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.Run(CompilerTextWriter consoleOutput, CancellationToken cancellationToken) in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 349
at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.CreatePackageRequestHandler.<Build>d__8.MoveNext() in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\CreatePackageRequestHandler.cs:line 174
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.CreatePackageRequestHandler.<HandleAsync>d__7.MoveNext() in F:\a\586\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\CreatePackageRequestHandler.cs:line 103
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase1.
To Reproduce Steps and to reproduce the behavior:
- Go to '...'
codeunit 52157423 "Job List Events" { // 20190117 PBPA01 HM Events Created // 20190310 PBPA01 AD Project Task Log Event Created
trigger OnRun()
begin
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'OnAfterActionEvent', 'Request approval', false, false)]
local procedure OnRequestApprovalActionJobList(var Rec: Record Job)
var
//Job: Record Job;
Defaultprojectstatus: Record "Default project status";
NoStatusFoundError_Lbl: Label 'No Status Code found with project type %1.';
begin
//Purpose = To change job status to request approval & update job list too..
//PBPA01 20190117 HM <<
Defaultprojectstatus.RESET();
Defaultprojectstatus.SETRANGE("Project type", Rec."Project Type");
Defaultprojectstatus.SETRANGE("Status Type", Defaultprojectstatus."Status Type"::"Project Requested");
IF Defaultprojectstatus.FINDSET() THEN BEGIN
Rec.VALIDATE("Status Code", Defaultprojectstatus."Status Code");
Rec.VALIDATE("Status Type", Defaultprojectstatus."Status Type");
END ELSE
ERROR(NoStatusFoundError_Lbl, Rec."Project Type");
//PBPA01 20190117 HM >>
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'OnAfterActionEvent', 'Project Status', false, false)]
local procedure OnProjectStatusActionJobList(var Rec: Record Job)
var
ProjectStatus: Record "Project Status";
DefaultProjectstatustasks: Record "Default Project status tasks";
begin
//Purpose = To Open Project Status Page
//PBPA01 20190117 HM <<
ProjectStatus.RESET();
ProjectStatus.SETRANGE("Project Type", Rec."Project Type");
ProjectStatus.SETRANGE("Project No.", Rec."No.");
PAGE.RUNMODAL(0, ProjectStatus);
//PBPA01_HM_170119 >>
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'OnAfterActionEvent', 'Project Tasks', false, false)]
local procedure OnProjectTaskActionJobList(var Rec: Record Job)
var
ProjectTasks: Record "Project Tasks";
begin
//Purpose = To Open Project Task Page
//PBPA01 20190117 HM <<
ProjectTasks.RESET();
ProjectTasks.SETRANGE("Project No.", Rec."No.");
PAGE.RUNMODAL(0, ProjectTasks);
//PBPA01_HM_170119 >>
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'OnAfterActionEvent', 'Change Status', false, false)]
local procedure OnChangeStatusActionJobList(var Rec: Record Job)
var
Defaultprojectstatus: Record "Default Project status";
Defaultprojectstatus1: Record "Default project status";
ProjectTasks: Record "Project Tasks";
begin
//Purpose = To perform change status
//PBPA01 20190117 HM <<
Defaultprojectstatus.RESET();
Defaultprojectstatus.SETCURRENTKEY("Sort Number");
Defaultprojectstatus.SETRANGE("Project type", Rec."Project Type");
Defaultprojectstatus.SETRANGE("Status Code", Rec."Status Code");
IF Defaultprojectstatus.FINDFIRST() THEN BEGIN
Defaultprojectstatus1.RESET();
Defaultprojectstatus1.SETCURRENTKEY("Sort Number");
Defaultprojectstatus1.SETRANGE("Project type", Defaultprojectstatus."Project type");
Defaultprojectstatus1.SETFILTER("Sort Number", '>%1', Defaultprojectstatus."Sort Number");
IF Defaultprojectstatus1.FINDFIRST() THEN BEGIN
ProjectTasks.RESET();
ProjectTasks.SETRANGE("Status Code", Defaultprojectstatus1."Status Code");
IF ProjectTasks.FINDFIRST() THEN
ProjectTasks.MODIFYALL("Send On", TODAY());
Rec.VALIDATE("Status Code", Defaultprojectstatus1."Status Code");
Rec.VALIDATE("Status Type", Defaultprojectstatus1."Status Type");
END;
END;
//PBPA01 20190117 HM >>
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'CreateInteractionForJob', '', false, false)]
[Scope('Internal')]
procedure CreateInteractionForJobList(pJob: Record Job)
var
TempSegLine: Record "Segment Line" temporary;
Contact_lRec: Record Contact;
ContactName: Text;
begin
//Purpose = To perform create interaction
//PBPA01 20190117 HM <<
IF Contact_lRec.GET(pJob."Bill-to Contact No.") THEN
TempSegLine.DELETEALL();
TempSegLine.INIT();
IF Contact_lRec.Type = Contact_lRec.Type::Person THEN
TempSegLine.SETRANGE("Contact Company No.", Contact_lRec."Company No.");
TempSegLine.SETRANGE("Contact No.", Contact_lRec."No.");
TempSegLine.VALIDATE("Contact No.", Contact_lRec."No.");
IF TempSegLine."Salesperson Code" = '' THEN
TempSegLine."Salesperson Code" := Contact_lRec."Salesperson Code";
IF Contact_lRec."Company No." <> '' THEN
ContactName := Contact_lRec."Company Name"
ELSE
ContactName := Contact_lRec.Name;
TempSegLine."Wizard Contact Name" := ContactName;
TempSegLine."Wizard Step" := TempSegLine."Wizard Step"::"1";
TempSegLine."Interaction Successful" := TRUE;
TempSegLine.VALIDATE(Date, WORKDATE());
TempSegLine."Job No." := pJob."No.";
TempSegLine."Time of Interaction" := DT2TIME(ROUNDDATETIME(CURRENTDATETIME() + 1000, 60000, '>'));
TempSegLine.INSERT();
PAGE.RUN(PAGE::"Create Interaction", TempSegLine, TempSegLine."Interaction Template Code");
//PBPA01 20190117 HM >>
end;
[EventSubscriber(ObjectType::Page, Page::"Job List", 'InteractionlogEntriesForJob', '', false, false)]
[Scope('Internal')]
procedure OnOpenInteractionforJobs(var pJob: Record Job)
var
jobRec: Record Job;
InteractionlogEntryRec: Record "Interaction Log Entry";
begin
//Purpose = To perform on open interaction from job list
//PBPA01 20190117 HM <<
CLEAR(InteractionlogEntryRec);
InteractionlogEntryRec.FILTERGROUP(10);
InteractionlogEntryRec.SETRANGE("Job No.", pJob."No.");
IF InteractionlogEntryRec.FINDFIRST() THEN;
PAGE.RUN(PAGE::"InteractionLog Entries For Job", InteractionlogEntryRec, InteractionlogEntryRec."Job No.");
InteractionlogEntryRec.FILTERGROUP(0);
//PBPA01 20190117 HM >>
end;
[EventSubscriber(ObjectType::Page, 89, 'OnAfterActionEvent', 'Project Task Log', false, false)]
local procedure OnProjctTaskLogActionEvent(var Rec: Record Job)
var
TblProjectTaskLog: Record "Project Task Log";
begin
//PBPA01 20190310 AD <<
TblProjectTaskLog.RESET();
TblProjectTaskLog.SETRANGE("Job No.", Rec."No.");
PAGE.RUNMODAL(0, TblProjectTaskLog);
//PBPA01 20190310 AD >>
end;
}
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
5. Versions:
- AL Language: 4.0.182565
- Business Central: BC140 Cu3 Spring release 2019
@stijn9830, thank you for reporting this issue. This looks like similar to #5292
Hi @qutreson Thanks for your quick reply this has indeed solved my problem eventsubscriber onafteraction to not existing action on the page gives this error. Where it used to trow an specific error, it gives this error above