This is my code and i get this error
Job finished executing. Status: Error Error: An error occurred and the transaction is stopped. Contact your administrator or partner for further assistance.
Yes I tried debuging but it does not give any good info
and I added these to prevent the GUI
[EventSubscriber(ObjectType::Codeunit, 81, 'OnBeforeConfirmSalesPost', '', FALSE, FALSE)]
local procedure SkipDialogs(var DefaultOption: Integer; var HideDialog: Boolean; var SalesHeader: Record "Sales Header")
begin
if SalesHeader."Document Type" = SalesHeader."Document Type"::Order then begin
if SalesHeader.Xee_IsPostedFromJob then begin
DefaultOption := 3;
HideDialog := true;
SalesHeader.Ship := true;
SalesHeader.Invoice := true;
end;
end;
end;
[EventSubscriber(ObjectType::Codeunit, 80, 'OnBeforePostSalesDoc', '', false, false)]
local procedure HideProgressDialog(var HideProgressWindow: Boolean; var SalesHeader: Record "Sales Header")
begin
if SalesHeader."Document Type" = SalesHeader."Document Type"::Order then
if SalesHeader.Xee_IsPostedFromJob then begin
HideProgressWindow := true;
end;
end;
Also did you try with Ship and Invoice Boolean fields value, what you want to post?
Did you debug the problem?
I tried the same thing on purchase order and it runs successfully and the posting works when doing manually so I don`t think it is permission problem, and I tried writing this
if not SalesPost.Run(SalesHeader) then begin
Error('Error posting sales order %1', SalesHeader."No.");
// log your error in some table and later resolve the identified cause
// use some already available functions like GetLastErrorText()., GetLastErrorCode() for reference.
end;
but it does not go into the SalesPost.Run() it just crash there
Hi Muaaz Deyab
It seems like there could be a few issues with your code that are causing the error. Here are a few things to check:
Make sure that the variables and functions you are using are declared and defined properly. For example, you are using the variable myInt
but it is not being used or defined anywhere in the code.
Check if the SalesPost.Run
function is returning an error message. You can try adding a condition to handle any errors that may occur during the posting process. For example:
if not SalesPost.Run(SalesHeader) then begin
Error('Error posting sales order %1', SalesHeader."No.");
// log your error in some table and later resolve the identified cause
// use some already available functions like
GetLastErrorText()., GetLastErrorCode() for reference.end;
Ensure that the permissions for the user running the job are set up correctly. The user should have the necessary permissions to post sales orders and modify sales header records.
Check if there are any customizations or extensions that could be interfering with the code. Try disabling any customizations and extensions and then run the code again to see if it works.
Make sure that the job is being run with the appropriate company context. If the job is being run in a different company context than the sales orders that need to be posted, then it may not work.
I hope these tips help you resolve the issue. If you need further assistance, feel free to ask!
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,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156