coding

Where to write code in forms to display the sales information of customers by filtering the purchase date..

Answers

  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    [ 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 Veenendaal
  • dynamics navdynamics nav Member Posts: 50
    purchase date is the field I added in sales invoice line means that the date that customer purchased something
  • dynamics navdynamics nav Member Posts: 50
    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..
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    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 Veenendaal
  • dynamics navdynamics nav Member Posts: 50
    edited 2016-07-27
    I tried what you said but the form was not working....
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    If you show more of what you have done it becomes easier for (me and) the rest of us to help you....
    Jan Veenendaal
  • dynamics navdynamics nav Member Posts: 50
    edited 2016-08-27
    ok
  • RathiRathi Member Posts: 51
    can anyone elaborate more on this function
    CurrForm.SalesLines.FORM.MyFilterFunction(FromDate,ToDate); ??

    Need help
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    edited 2016-10-27
    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 Veenendaal
Sign In or Register to comment.