We want to create a Job Queue which will post purchase documents in a specific state. You would have previously achieved this via looping through the purchase headers and calling If Codeunit.Run...In this scenario previously you were able to retreive an error message, example below.
if PurchaseHeader.findset() then
repeat
if not Codeunit.Run(Codeunit::"Purch-Post", PurchaseHeader) then
// Do something with GetLastErrorText
until PurchaseHeader.Next() = 0;
Importantly, the Job Queue Entry would not fail at this point either, as the error was handled separately. I found this blog post with a similar query, but does anyone know how this is achieved now.
https://github.com/microsoft/ALAppExtensions/issues/16362
Essentially, we want to post orders via a job queue, and store any errors on the document. But we do not want the Job Queue Entry itself to go into error.
You have to write your PurchPost.run on OnRun trigger of Codeunit B.
Thanks.
Thank you Nitin,
I have the following setup:
Codeunit A is the target codeunit of the Job Queue.
In Codeunit A I have a function which calls codeunit B with if not CodeunitB.Run then;
Codeunit B Run is then calling if not PurchPost.Run.
I think the error context however is at the job queue level, and therefore even with the additional codeunit, the error is still considered under the context of the job queue. My Job Queue is still failing with a posting date error.
You have to write one more codeunit and write your posting functions in that codeunit, and use that codeunit in another objects like below
if not PostingCodeunit.run then
begin
LogyourError here with functions GETLASTERRORTEXT.
end;
by doing above your job queue will never be in Error.
Thanks.
Hello,
We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
I will open this up to the community in case they have something to add.
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156