Filtering records in a form

Hi there Maybe this should go in the Navision End User section… I’d like to filter a list form so that when it opens, only certain records can be seen in the list. For example, list form A lists all the sales lines, but we don’t want to see the records where quantity = flowfieldAqty + flowfieldBqty. I’m sure there must be a simple way to do this, but I can’t find it. Can anyone advise? Many thanks…

Robbie, This is a tough one, you cannot have filters in Navision which are dependent of values in other fields, expecialy not with formula’s The best you can do is create a codeunit which does the following: 1. Create a temporary instance ot the salesline 2. Write a loop through the real saleslines and copy it to the temp record if it maches your requirements. 3. Run the form you want on the new temporary table. Suc6. Mark.

HI Robbie, this is uite simple, but it will take a lot of experimenting to get it to work. Basically you need to put code in the OnNextRecords, and OnFindRecord triggers of the form. OnNext basically says what to do when you do a next (Up/Down) on the form, in your case if the next record does not meet your requirements, then do another next. OnFind is when you do a find on a form,. that could be Ctrl F, or Page Down etc. In this case, you tell the form the record was not found unless it fits yourcriteria. Just one thing, this works ine for say X + Y > 0, but is problematic for flow fields, since you need to be on the record to do the calcfields and this need to be done nefore you get to the record, so with Flow fields you will probably be better off defining a new record to do the calcfields. Hope this helps, let me know if you need more help.

Check out the following to see examples of the code David is talking about in OnFindRecord and OnNextRecord.

Mark, David, Jack! Many thanks indeed for your support! In some ways I’m pleased it’s not so straight forward…now I understand why I couldn’t work out how to do it on my own! :slight_smile: I’m going to attempt your suggestions. Much appreciated… Robbie

Jack, that’s a very good post, I have posted many postings on this topic, but none so detailed. I will though add my favourite bit I normally put when posting on this topic, and that is my love of the Danglish language. When I first tried to do this ( Navision Fin 0.9 some time ago), the help was pretty abysmal, but I tried to follow the steps to get some code to work in the OnNextrecord. It didnt work, so I commented out the code, only to {eventually} find that the help says “Any code entered here will replace the standard function”. Of course that meant a commented line would repalce the standard functionality. i.e. put a // and the form is dead. Forms are fun in Navision, and a great place to learn all the tricks of the trade, but remember to read literally every line of the help and manuals.