Recreating the Get Shipment Lines Form

tompynation
Member Posts: 398
Hi,
I am recreating the Get Shipment Lines form so that you can just run this form from the Object designer or the Menu...
So you do not have to create the Invoice first before you can use this form.
Now this is all easy but i have a question.
i created a new Form "Shipped not Invoiced". This form has the table view set to:
WHERE(Qty. Shipped Not Invoiced=FILTER(<>0))
The form just contains a tablebox to display the "Sales Shipment Lines", and a button to create the Invoice(s) for the Selected Shipment Lines.
Now my question is, how can i get all the Lines that the User has Selected, when he presses the button to create the Invoices?
I am recreating the Get Shipment Lines form so that you can just run this form from the Object designer or the Menu...
So you do not have to create the Invoice first before you can use this form.
Now this is all easy but i have a question.
i created a new Form "Shipped not Invoiced". This form has the table view set to:
WHERE(Qty. Shipped Not Invoiced=FILTER(<>0))
The form just contains a tablebox to display the "Sales Shipment Lines", and a button to create the Invoice(s) for the Selected Shipment Lines.
Now my question is, how can i get all the Lines that the User has Selected, when he presses the button to create the Invoices?
0
Comments
-
Lookup SetSelectionFilter in the helpfile0
-
Well, i see how it works but how can i use this?
I am showing all Sales Shipment Lines, not filtered on the "Bill-to Customer No."
So the user can select from Multiple Shipments, and for different Customers
So will need two fields from the Filter:
1. The Document No.
2. The Line No.
How can i do this? So that i get the "Line No." filter per "Document No." ?0 -
Make a new variable of the same type as the record ( let's call it NewRec ) , then with the following code, you can loop through all the selected lines the user has selected :
currform.setselectionfilter(NewRec) ; if newrec.find('-') then //Replace with FindSet if your version supports it repeat // do something with Newrec."Document No.",NewRec."Line No." until NewRec.next = 0
0 -
allright, thanks, that was what i needed...0
-
I allmost got it working entirely... But still there is a problem:
When i select a Sales Shipment Line with "Bill-to Customer No." = 12345
and a Sales Shipment Line with "Bill-to Customer No." = 54321
Then i receive following error:
The Bill-to Customer No. on the Sales Header 1036 and the Sales Shipment Header 102049 must be the Same
The first Invoice gets correctly created. This has the no. 1036
But when it should generate the new Invoice for the 2nd selected
Sales Shipment Line then it gives the error. The 2nd selected Sales Shipment Line, comes from the Sales Shipment Header 102049
Following code creates the Sales Header(s) and Invoice Line(s) on a button Click:[b]<Control1000000021> - OnPush()[/b] lv_BillTo := ''; CurrForm.SETSELECTIONFILTER(lv_SalesShptLine); lv_SalesShptLine.SETCURRENTKEY("Bill-to Customer No."); IF lv_SalesShptLine.FINDSET THEN BEGIN REPEAT CLEAR(ShptMgmnt); //Indien "Bill-to Customer No." wijzigt nieuwe SalesHeader aanmaken IF lv_BillTo = '' THEN BEGIN CreateSalesHeader(lv_SalesShptLine."Bill-to Customer No.",lv_SalesShptLine."Sell-to Customer No."); ShptMgmnt.SetSalesHeader(gv_InvoiceHeader); ShptMgmnt.CreateInvLines(lv_SalesShptLine); lv_BillTo := lv_SalesShptLine."Bill-to Customer No."; END ELSE IF lv_BillTo <> '' THEN BEGIN IF lv_BillTo <> lv_SalesShptLine."Bill-to Customer No." THEN BEGIN CreateSalesHeader(lv_SalesShptLine."Bill-to Customer No.",lv_SalesShptLine."Sell-to Customer No."); ShptMgmnt.SetSalesHeader(gv_InvoiceHeader); ShptMgmnt.CreateInvLines(lv_SalesShptLine); END ELSE IF lv_BillTo = lv_SalesShptLine."Bill-to Customer No." THEN BEGIN ShptMgmnt.SetSalesHeader(gv_InvoiceHeader); ShptMgmnt.CreateInvLines(lv_SalesShptLine); END; END; // IF CONFIRM(Text001) THEN BEGIN // FORM.RUNMODAL(43,gv_InvoiceHeader); // END; UNTIL lv_SalesShptLine.NEXT = 0; END;
As you can see i create New Sales Header, every time the "Bill-to Customer No." switches.
CreateSalesHeader(varBillToCust : Code[20];varSellToCust : Code[20])
gv_InvoiceHeader.RESET;
gv_InvoiceHeader.INIT;
gv_InvoiceHeader.VALIDATE("Document Type",gv_InvoiceHeader."Document Type"::Invoice);
gv_InvoiceHeader.VALIDATE("No.",'');
gv_InvoiceHeader.INSERT(TRUE);
gv_InvoiceHeader.VALIDATE("Sell-to Customer No.",varSellToCust);
gv_InvoiceHeader.VALIDATE("Bill-to Customer No.",varBillToCust);
gv_InvoiceHeader.MODIFY(TRUE);
Somebody who see's something wrong with my code/logic ??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