ReqFilterFields not populated by OnLookup trigger

Problem: When you write your own OnLookup() trigger code on a table and then has this field as a ReqFilterField on a report, the lookup doesn’t return the selected value. Solution: ? Soren Nielsen, moderator Integration/Developer NOLUG

Søren, I’m not quite sure I understand what you’re writing here. Could you maybe explain it a little deeper? Best regards, Erik P. Ernst, webmaster Navision Online User Group

If you define a table-relation for your field AND in addition the code in the OnLookup-Trigger, then the Lookup should work in the Request-Form (with your Lookup-Code). Does this fix your problem ? Richard

Soren you cannot drill down on the properties for the requestform TextBox table Relation with a Variable or field Source. What I do is go to the table copy and paste the Field Table Relation I want, or create a new field set the table Relation copy it and dont save the changes. Then paste the table Relation to the text box properties! If you want to write your own on lookup then return the value from the lookup to a Variable and then use the variable in code to load the value! IF FORM.RUNMODAL(FORM::“Item Ledger Entries”,ItemLedgEntry) = ACTION::LookupOK THEN ItemNo:=ItemLedgeEntry.“Item No.”; David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk Edited by - David Cox on 2001 Mar 27 20:22:03

quote:


Problem: When you write your own OnLookup() trigger code on a table and then has this field as a ReqFilterField on a report, the lookup doesn’t return the selected value. Solution: ?


Ok, seems like i have to explain this in more detail. What i have i a fully functional OnLookup() trigger code on a table. When using this in the table/form it works fine, and the field is being populated by the lookup code. My problem is when running a report based on this table. As one of my ReqFilterFields i have this field, for which i have this custom OnLookup() code for, but it will not return a value to the reports filter. So lets say my table is ‘Catalog’, then on my report first dataitem i have a ReqFilterField eg. ‘Catalog.“Item No.”’ when hitting F6, and selecting a value from the lookup, it is not returned to the “filter”. Help? Soren Nielsen, moderator Integration/Developer NOLUG

I don’t know solution. Problem is that report forms is not the same as forms. They showing not selected value, but filter on the field. Form shows: :=Catalog.“Item No.”; ReportForm shows: :=Catalog.GetFilter(“Item No.”); Try onLookUp use SetRange or SetFilter and you will see that report will show selected value. After lookup move currsor up and down, becouse CurrForm Update is not called then using own lookup. So one problem is solved. Now we got another. HOW TO RECOGNIZE LOOKUP CALLED FROM FORM OR FROM REPORT?

Hi Dalius, i found this work-around myself too. But as you mention i have a problem when using this as normal table/form lookup :frowning: Unfortunately i don’t think there is a way of knowing where the OnLookup() is called from. So it seems like i’m stuck. Soren Nielsen, moderator Integration/Developer NOLUG

Soren Put a TextBox on the request form options tab with your lookup code pasted in the trigger of the textbox, take the field off the field list. Use a variable to return your lookup value to, then on PreDataItem use the value to filter the recordset. Or am I missing something here? David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk

David, i know i can fix it with your solution! But just kind of annoying that when you have several dataitems dataitems, and thus several field lists, for the customer to remember set additional filters on the “Options” tab - just because you have coded your own OnLookup() trigger! Soren Nielsen, moderator Integration/Developer NOLUG

Soren, Your can try another two ugly solutions: 1. Remove OnLookUp code from table, put it on forms. 2. In this table meke new dummy field. Bool or another type. In report use DataItemTableView set filter that don’t have any influence to table on this field. Or you can use existing field: if bool set ‘Yes|No’. In lookup code add:


FilterGroup(2)
IF GetFilter(dummy)<>'' THEN 
    SetRecFilter();
 

This is would be nice,but report form isn’t refreshed & looks ugly.

Thanks for the hints, but nothing seems to work the way I want it to. Hopefully Navision fixes this in a upcoming release… Yeah right :slight_smile: Soren Nielsen, moderator Integration/Developer NOLUG Edited by - SNielsen on 2001 Apr 26 17:51:14