Coding to copy previous sales order line

ellusivelady
Member Posts: 23
HELP NEEDED
Added SubOrderNo code 20 to Sales Header table.
Added OrderRefNo text 30, SubOrderNo code 20 to Sales Line table.
When Sales Order form is opened, Sales Order Line will setrange based on Sales Header SubOrderNo.
By default, Sales Line SubOrderNo will be the same as Sales Header SubOrderNo.
eg. Sales Header: Document No. = 10010
SubOrderNo = 1
Sales Line: (1st line) OrderRefNo = ER1 Order (manually key)
SubOrderNo = 1
Item = 133
(2nd line) OrderRefNo = ER1 Order (should be auto)
SubOrderNo = 1
Item = 135
Each time i create a new line, I want the system to automatically copy the OrderRefNo from the previous line. Only applicable to 2nd line onwards.
I can't assign another variable(eg. storeOrderRef) to OrderRefNo. It will only work for this SubOrderNo. Cause if I create another SubOrderNo (i.e. 2) for Document No. 10010, and if I go back to the previous SubOrderNo (i.e. 1), I cannot use variable storeOrderRef cause the OrderRefNo will now be different(cause it will reflect that of SubOrderNo 2).
I hope my explanation is clear enough and you understand what I'm trying to say.
Thanks.
Added SubOrderNo code 20 to Sales Header table.
Added OrderRefNo text 30, SubOrderNo code 20 to Sales Line table.
When Sales Order form is opened, Sales Order Line will setrange based on Sales Header SubOrderNo.
By default, Sales Line SubOrderNo will be the same as Sales Header SubOrderNo.
eg. Sales Header: Document No. = 10010
SubOrderNo = 1
Sales Line: (1st line) OrderRefNo = ER1 Order (manually key)
SubOrderNo = 1
Item = 133
(2nd line) OrderRefNo = ER1 Order (should be auto)
SubOrderNo = 1
Item = 135
Each time i create a new line, I want the system to automatically copy the OrderRefNo from the previous line. Only applicable to 2nd line onwards.
I can't assign another variable(eg. storeOrderRef) to OrderRefNo. It will only work for this SubOrderNo. Cause if I create another SubOrderNo (i.e. 2) for Document No. 10010, and if I go back to the previous SubOrderNo (i.e. 1), I cannot use variable storeOrderRef cause the OrderRefNo will now be different(cause it will reflect that of SubOrderNo 2).
I hope my explanation is clear enough and you understand what I'm trying to say.
Thanks.
0
Answers
-
1) You can use the PopulateAllFields property on the form to fill all fields with the value to which the field is filtered on (if it is simple value).
2) If your new field is not part of the primary key of the Lines (it means that you extended the PK of the table), you will have problems with the AutoSplitKey functionality when entering the lines into the order if you will filter the lines in this way... I recommend to thing about that...0 -
Hi Ellusivelady
Try to put some code, to the "No." validate trigger of the sales line. SalesLine is a local variable of type Record from table 37.// Copy rec filters SalesLine.Copyfilters(Rec); // If SalesLines are not filtered by SubOrderNo then You need it to filter // the record set: // SalesLine.SETFILTER(SubOrderNo , NowUsedSubOrderNo ); IF SalesLine.COUNT > 1 THEN BEGIN // THERE IS AT LEAST ONE RECORD OF SEALS LINE SalesLine.FIND('+'); REC.OrderRefNo := SalesLine.OrderRefNo; END ELSE BEGIN // You don't have any rec. created yet. REC.OrderRefNo := 'What ever You want'; END;
If this is not helping You, try to write the problem more clearly.
I will try to help You then.
GoodLuck0 -
hi All,
thanks so much for your help.
But to kine, unfortunately, I can't use the PopulateAllFields as my data defers.
As for krzychub83, tanx for ur code. I did tried that before i post here but it didn't entirely work. :-s tanx though.
In my main Sales Order, I can have multiple suborders.
I managed to solved it though. I created a table to store the unique suborder number. From there, if user select a particular number, the details will follow accordingly. dat seems to be d best way out. on top of that, i remove the autosplitkey function n automaticaly assign my own line no.
Thanks once again all.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions