Hi Every One,
I try a copy sales order A to B company on Nav 2013. It's perfectly working but when i delete a sales line record on A Company, i can't delete ReserveSalesLine.DeleteLine(rec) on B company.
How can i use this codeunit on B company
Thanks for help
0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
We have 2 company on our NAV 2013. A company for only sales and marketing(EVG) other company only for manufacturing(ANK). All sales order opening EVG company and we are copy this order to ANK company manually. After we are run planing on ANK company...
I write a Codeunit for this situation and running smootly. But only delete processes does not work properly.
My code below
.
.
.
.
AnkSalesLine.SETRANGE("No.",Rec."No.");
AnkSalesHeader.RESET();
AnkSalesHeader.CHANGECOMPANY('ANK');
AnkSalesHeader.SETRANGE("No.",Rec."Document No.");
IF (AnkSalesHeader.FINDFIRST) AND (AnkSalesHeader.Status = AnkSalesHeader.Status::Open) THEN BEGIN
IF AnkSalesLine.FINDFIRST THEN
ERROR('blablabalba');
CapableToPromise.RemoveReqLines(AnkSalesLine."Document No.",AnkSalesLine."Line No.",0,FALSE);
ReserveSalesLine.DeleteLine(AnkSalesLine);
AnkSalesLine.DELETE();
END ELSE BEGIN
ERROR(Text061);
END;
The red words not working ANK company with changecompany function. How can i run this 2 function on ANK company
In OnRun (Sales Header record ) as parameter
You Code .. to delete without the change company.
You will then call this Codeunit from your process this way.
STARTSESSION(SessionID,50000,'ANK',SalesHeader);
your code will not work because t executes in current company. You are only changing company on salesheader, all other code is run in current company
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n