0
votes

I am triing to figure out where the status code will be changed. Because If I try to book a order. and something goes wrong.then there will be a rollback. But in present day the status code will be changed, what not has to be. Because you cant book the whole order after. Status code has to be unchanged.

enter image description here

enter image description here

enter image description here

Thank you

The status code will be changed after this error: enter image description here

And yes, I debugged the code

and in code unit: 7301 on this line:

END ELSE
    IF FromBinContent."Quantity (Base)" + "Qty. (Base)" < 0 THEN
      FromBinContent.FIELDERROR(
        "Quantity (Base)",STRSUBSTNO(Text000,FromBinContent."Quantity (Base)"));
END;

I will get the error

Thank you

Oke, I found the piece of code where status code will be changed.

lRecStatus.FILTERGROUP(4);
lRecStatus.SETRANGE("Change Status",lRecStatus."Change Status"::Released);
lRecStatus.FILTERGROUP(0);
IF NOT lFncNextStatus2(vRecSalesHeader,lRecStatus,FALSE,FALSE) THEN
  ERROR(lCtx000,vRecSalesHeader."Document Type",vRecSalesHeader."No.",vRecSalesHeader."Status Code");
  lRecStatus.SETRANGE("Change Status",lRecStatus."Change Status"::01-NEW);

vRecSalesHeader.FIND('=');

So I added this:

 lRecStatus.SETRANGE("Change Status",lRecStatus."Change Status"::01-NEW);

But how to set the value New - how it was? and not that the code goes to "vrijgegeven"?

Thank you

Oke. I found in codeunit: 1107570 this:

lRecStatus.FILTERGROUP(4);
lRecStatus.SETRANGE("Change Status",lRecStatus."Change Status"::Released);
lRecStatus.FILTERGROUP(0);
IF NOT lFncNextStatus2(vRecSalesHeader,lRecStatus,FALSE,FALSE) THEN
  ERROR(lCtx000,vRecSalesHeader."Document Type",vRecSalesHeader."No.",vRecSalesHeader."Status Code");
vRecSalesHeader.FIND('=');

and if I comment this:

IF NOT lFncNextStatus2(vRecSalesHeader,lRecStatus,FALSE,FALSE) THEN
  ERROR(lCtx000,vRecSalesHeader."Document Type",vRecSalesHeader."No.",vRecSalesHeader."Status Code");

then the status code will not been changed. But I dont know if this is correct, because maybe somewhere else goes wrong.

Thank you

1
I am not sure if you are trying to remove the status change completely, or just deal with the situation of it updating even when the transaction rolls back due to an error. The codeunit 1107570 means that this should be an ISV Solution Numbering Conventions; you'll have the best results discussing what your trying to accomplish with the original authors of the code. If your still looking to do this, you need to review the code in lFncNextStatus2 and then preform some testing on the changed system. - Akedren

1 Answers

0
votes

If the status code is remaining updated after an error message, then the most likely cause is that a COMMIT has been issued after the posting routing is called but before the error message.

The OMS Tab on your Sales Order is appears to be the result of ether an ISV add-on or database specific customization, so it is hard to say for sure where the suspect code would be, there are a number of ways to find it.

The most straight forward way to find the code would be to user the Debugger (Tools -> Debugger -> Active / Breakpoint on Triggers) while repeating the process and step-in / over the transactions until you encounter a COMMIT statement.

If your more familiar with C/AL code (and have a sufficient license / permissions) you can open the form for modification and manually trace the code used to post the document.

Refactoring the code to remove a COMMIT can be quite tricky and if it is being changed inside the posting routing would likely require your Dynamics Partner or ISV to make the modification due to how the development license structure works.