Filter On field given by a variable ?

hi, is it possible to setrange oder filter with a variable which contains the name of the field like this .SETRANGE(variablename,variablevalue) ? i think not but i need such a function for a user-search formular ! … how to solve it ? thx *** quack ***

What is it exactly that you’re trying to do ?

On the negative side, C/AL does not support much indirect addressing (a couple of minor exceptions) nor can you modify C/AL code dynamically (at run time). But if I interpret your question totally literally, what you’ve described is exactly how Navision works. So I need to echo Hannes’ question: What is it you’re trying to do? Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner

It sounds as though you need to decide which fields the user may want to filter on and use a case statement to set the filters, since Navision doesn’t really do indirect referencing. Something like: CASE My_Field_Name OF ‘No.’: SETRANGE(“No.”, My_From_Value, My_To_Value) ‘Department Code’: SETRANGE(“Department Code”, My_From_Value, My_To_Value) etc. It’s clumsy but you can’t actually use a variable as the first parameter in SETRANGE or SETFILTER. Dan.

I know exactly what you want to do! I have done something similar, but as dan says, you have to have the code. I did a add-on, to ensure some mandatory field is populated, before it is possible to unblock ie. the Item Card. Have a look, this might help you. [This is where the file should have been, but I get an asp-error trying to upload the file - send me an e-mail (henrik@helgesen.info) with your e-mailaddress and I will mail it to you] //Henrik Helgesen -: KISS::Keep it Simple, Stupid :-

for those who don’t understand me … i want to set a filter on a field and the field in the setrange-function is given by a variable … so the user chooses a fieldname out of a combobox then the filter is set with the choosen field(name) … for a caseOf it is to much :slight_smile: and not dynamic enough for me so i searched for another solution … *** quack ***

I have a related question. Can you send a field as parameter of a function.

Because I’m trying to do this:

Bold words are variable and given as parameter.

Thx

Locutus

A lot of problems are solved by using RecordRef, FieldRef, etc.

Take a look at the “Application Designers Guide” - perhaps you find your solution there.