coding

dynamics nav
Member Posts: 50
Where to write code in forms to display the sales information of customers by filtering the purchase date..
0
Answers
-
[ general remark: NEVER write code on forms, unless absolutely necessary. Write code in the source table, or in a (dedicated?) codeunit ]
What do you mean by 'purchase date' ? - is that the date that your customer purchased something from you, or is it the date that you purchased the item from your supplier?
Jan Veenendaal0 -
purchase date is the field I added in sales invoice line means that the date that customer purchased something0
-
I created a form using the sales invoice header and sales invoice line added 3 fields in main form i.e, customer no, from date and to date,and in sub form i taken the fields like item no,line no,document no,customer no, purchase date and to date. Now my task is to display the sales of an customer during the from date and to date..please say me how to filter the sales..0
-
I presume that the date fields on the header are not actually fields in the sales invoice header. In this case you should probably need to do:
1. Create a function on your subform [so far for my 'general remark'] with 2 parameters of type 'Date'. This function should have code something like:
SETRANGE("Purchase Date", FromDateParameter, ToDateParameter);
2. Create a function on your main form that calls the function on your subform and provides the values of the date-fields that you added to this form. Code looks something like:CurrForm.SalesLines.FORM.MyFilterFunction(FromDate,ToDate);
(I have no Classic Client available; I'm not sure about the location of '.FORM.' in this code)
3. Call this last function from the 'OnValidate' trigger of both date fields.
Some more remarks:
- are you aware of the fact that Sales Invoice records can be deleted after they are printed once? So your list might be incomplete.
- You miss returned / credited item information.
- Probably you should use the 'Item Ledger Entry' table to get your information. Records cannot be deleted from that table, and also returned items are in there. Also all fields that you need are available somehow in that table - without any modification necessary.
Jan Veenendaal0 -
I tried what you said but the form was not working....0
-
If you show more of what you have done it becomes easier for (me and) the rest of us to help you....Jan Veenendaal0
-
ok0
-
can anyone elaborate more on this function
CurrForm.SalesLines.FORM.MyFilterFunction(FromDate,ToDate); ??
Need help0 -
When you write code on a form, you can use CurrForm to access controls on that form from your code.
On your form is a subform; to be able to access the subform from your code you have to give the subform a name. The common name for the subform on a Sales main form is 'SalesLines' - but you should check which name it is in your case. [that is why you need to share more code and screenprints: so members on this forum can use the actual names for your case]
The FORM is a NAV construction to allow you to access code that is actually on your subform.
MyFilterFunction is the name of the function that you create on the subform. FromDate and ToDate shoule be replaced by the actual names of the variables that you added to the main form.
Jan Veenendaal0
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