Problem with setting Filters on Forms by (f.)RUN

I tried to run a posted document form with RUN(id,record). I set a filter on the record but after form run there was no filter on the form. Later i found out that there is a SETRANGE(“No.”) on the OnAfterGetRecord-Trigger of this form. Now my question, why is there this SETRANGE?? Does it have to be there?? Thx for answer When answering with mail; please →

Hi Stefan


Originally posted by blum Now my question, why is there this SETRANGE?? Does it have to be there??

I don’t know! Perhaps to set the invoice lines [?]. The code below should work (no matter if there is setrange in OnAfterGetRecord): example: filter on customer 4070000

Name	DataType	Subtype	Length
!DebInvoice	Record	Sales Invoice Header	
!DebInvoiceForm	Form	Posted Sales Invoice	

"!DebInvoice".SETCURRENTKEY("!DebInvoice"."Sell-to Customer No.");
"!DebInvoice".SETRANGE("!DebInvoice"."Sell-to Customer No.",'4070000');


To Blum: This is one of development standards, dictated by Navision (card forms only). You can play with it to see its effect: 1. Comment it out, compile and save the card 2. Run the card 3. Open a list (f5) 4. Open second instance of the card (different or same record) by pressing Shift-F5 (DO not hit OK) 5. Open the list again, you will see one record there. The feature (bug?) is that the list form passes the filter when you hit OK, (equivalent to SETRECFILTER) that is then explicitly removed by the SETRANGE(“No.”) on the card forms. Believe it or NOT… Alex

Hi Blum, AlexZ is almost correct. The idea is that when you are in the list and the you open up the card the system transfers the filter also which in this case is the “No.” from the primary key. The reason you want to have that filter removed is so that the user is capable to scroll to the next records from the card. Ex: say in the list you are on record No. 3. Open card which takes you to No. 3. But then if you did not have that setrange when you pressed Page Down it will not do anything because you have filtered on No. 3. So you must remember to do that any time you make a List + Card combination for a new table Cristi

Why SETRANGE is there? Have You ever experienced a call from a desperate customer saying that “all my posted invoices have vanished!”? And later on You discover that the reason is a filter that “nobody” knows anything about? I heard from Navision that this is one reason. But this is not carried throug, not at all. E.g. in our company I have several times found emty orders belonging to the one and same customer. Reason: the salesperson (off course it has to be a salesperson [;)]) had set a filter on field “Customer no.”. And when creating av new order - it just “disappear”; solution: create a new order! Yes!!

Thx for all answers, now it is clear for me. I have to use another solution. @Anfinnur H.: hehe … We had such calls from our subsidiaries when they put filters on other forms … :wink: