Job Queue error message keep repeating the initial error
Please include the following with each issue:
1. Describe the bug Job Queue error message keep repeating the initial error
Whenever job queue fails it always shows the first error message
2. To Reproduce Steps to reproduce the behavior:
i) create a new job queue to post invoices ii) first block posting dates and try to post you will get error message says posting date restriction iii) then open the posting date period and block the customer and re run the job queue. iv) it will still says job queue failed due to posting date restriction
- Go to '...'
AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally.
namespace System.Threading;
using System.Utilities;
codeunit 450 "Job Queue Error Handler" { Permissions = TableData "Job Queue Entry" = rimd, TableData "Job Queue Log Entry" = rm; TableNo = "Job Queue Entry";
trigger OnRun()
begin
if Rec.DoesExistLocked() then begin
Rec.Status := Rec.Status::Error;
LogError(Rec);
end;
if Rec."Job Queue Category Code" <> '' then begin
Commit();
Rec.ActivateNextJobInCategory();
end;
end;
var
JobQueueContextTxt: Label 'Job Queue', Locked = true;
local procedure LogError(var JobQueueEntry: Record "Job Queue Entry")
var
JobQueueLogEntry: Record "Job Queue Log Entry";
ErrorMessages: Record "Error Message";
ErrorMessageManagement: Codeunit "Error Message Management";
ErrorMessageHandler: Codeunit "Error Message Handler";
ErrorContextElement: Codeunit "Error Context Element";
begin
JobQueueLogEntry.SetErrorCallStack(GetLastErrorCallStack()); // Set callstack for telemetry
OnBeforeLogError(JobQueueLogEntry, JobQueueEntry);
if IsNullGuid(JobQueueEntry."Error Message Register Id") then begin
ErrorMessageManagement.Activate(ErrorMessageHandler, false);
ErrorMessageManagement.PushContext(ErrorContextElement, JobQueueEntry.RecordId(), 0, JobQueueContextTxt);
JobQueueEntry."Error Message Register Id" := ErrorMessageHandler.RegisterErrorMessages(false);
ErrorMessageManagement.PopContext(ErrorContextElement);
end;
ErrorMessages.SetFilter("Register ID", JobQueueEntry."Error Message Register Id");
if ErrorMessages.FindFirst() then; // This is where the issue it should have been FINDLAST instead
JobQueueEntry."Error Message" := ErrorMessages."Message";
JobQueueEntry.Modify();
JobQueueLogEntry.SetRange(ID, JobQueueEntry.ID);
JobQueueLogEntry.SetRange(Status, JobQueueLogEntry.Status::"In Process");
if JobQueueLogEntry.FindFirst() then begin
JobQueueLogEntry."Error Message Register Id" := JobQueueEntry."Error Message Register Id";
JobQueueLogEntry."Error Message" := JobQueueEntry."Error Message";
JobQueueLogEntry.SetErrorCallStack(GetLastErrorCallStack()); // Need to save callstack before deleted above
JobQueueLogEntry.Status := JobQueueLogEntry.Status::Error;
JobQueueLogEntry.Modify();
#if CLEAN24 end; #else OnLogErrorOnAfterJobQueueLogEntryModify(JobQueueEntry); end else begin JobQueueEntry.InsertLogEntry(JobQueueLogEntry); JobQueueEntry.FinalizeLogEntry(JobQueueLogEntry, GetLastErrorCallStack()); OnLogErrorOnAfterJobQueueLogEntryFinalizeLogEntry(JobQueueEntry); end; #endif
OnAfterLogError(JobQueueEntry);
JobQueueEntry.FinalizeRun();
Commit();
end;
[IntegrationEvent(false, false)]
local procedure OnAfterLogError(var JobQueueEntry: Record "Job Queue Entry")
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeLogError(var JobQueueLogEntry: Record "Job Queue Log Entry"; var JobQueueEntry: Record "Job Queue Entry")
begin
end;
#if not CLEAN24 [IntegrationEvent(false, false)] [Obsolete('Event no longer relevant, it does the exact same as OnAfterLogError() and OnLogErrorOnAfterJobQueueLogEntryFinalizeLogEntry() is obsoleted.', '24.0')] local procedure OnLogErrorOnAfterJobQueueLogEntryModify(var JobQueueEntry: Record "Job Queue Entry") begin end; #endif
#if not CLEAN24 [IntegrationEvent(false, false)] [Obsolete('Event no longer relevant. Log entries should not be inserted if the job queue dispatcher did not manage to run the job.', '24.0')] local procedure OnLogErrorOnAfterJobQueueLogEntryFinalizeLogEntry(var JobQueueEntry: Record "Job Queue Entry") begin end; #endif }
Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.
3. Expected behavior A clear and concise description of what you expected to happen.
always display latest error message related to the job queue
4. Actual behavior A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring always showing first error message recorded against the job queue error id
5. Versions:
- AL Language:
- Visual Studio Code:
- Business Central:
- List of Visual Studio Code extensions that you have installed:
- Operating System:
- [x] Windows
- [ ] Linux
- [ ] MacOS
Final Checklist
Please remember to do the following:
-
[x] Search the issue repository to ensure you are reporting a new issue
-
[ ] Reproduce the issue after disabling all extensions except the AL Language extension
-
[ ] Simplify your code around the issue to better isolate the problem
Hi everyone,
I recently found an issue about Job Queue error message. It can't log the real error message which caused wrong direction of error check.
For example, I create a Job Queue Entry to run this CU that must return error. Suppose every error messages are different as I log the current datetime.
However, no matter how many times running this JQ Entry, it will only repeat the Error Message of initial run.
Only after I cleared the "Error Message Register Id", then I can log a new Error Message.
Is there any setup I miss to cause this?
Thanks to Leo chu for the content
This repository is only dedicated to bug reports for AL compiler and developer tools. Runtime issues should follow the support process indicated below.
You can also try reporting the bug in the BCApps repository which holds the system application.
How to get help
- Review our resources for help and support
- If you are a Microsoft Partner, follow the documentation here to escalate a customer issue
- If you are a Business Central customer, read about reporting a problem
- Open a bug in Collaborate
- Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company.
General Questions
You can use Viva Engage for asking questions and providing feedback around the runtime behavior of the product.