Getting the filters from Form to Codeunit

sabzamsabzam Member Posts: 1,149
Dear All,

How could I get the filter of the form and send it to the codeunit. THe navision surely does it but I have been lookin for it for hours and still couldn't find out how to solve it. I am not speakiong of the usual ones like batch name but for example if the user decides to filter by amount 500; I want to pass that over to the codeunit in question.

Comments

  • RobertJRobertJ Member Posts: 9
    Create a function in your codeunit that takes in a VAR parameter. This parameter should be based on the same table as your form.

    From within the function you can use GETFILTER etc on your parameter to retrieve the filters that were set on the form.
  • jlandeenjlandeen Member Posts: 524
    I normally recommend using a function to apply/copy filters like that...just remember not to use any of the existing keyworks like setfilter or copyfilters as your function name.

    Here's a simple code snippet (assumes inputrec is byref):
    if InputRec.GetFilters <> '' then 
      CodeunitRec.CopyFilters(InputRec);
    

    Then you can call this function in the codeunit with the record from the form your using. This process will copy any number of filters to the CodeUnitRec variable. I've used this pattern quite successfully in the past.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
Sign In or Register to comment.