Sales order Copy to another company
CeRBeR
Member Posts: 3
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
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
-
It's unclear what you are trying to do. You need to clarify your question and what you are trying to do.0
-
Hi @ara3n. Thank you for interesting.
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 company0 -
You need to create a new Codeunit for example called "Delete Sales Order" 50000.
In OnRun (Sales Header record ) as parameter
You Code .. to delete without the change company.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();
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 company0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
