Hi there!
I wan to set a filter in a form that shows only records based on a filter of 2 fields.
I know I can filter records field by field, but I want to create a filter of 2 fiels at the same time.
Basically I want to create a condition to set a filter.
How can I do it?
0
Answers
setfilter(field2,Condition2);
or do you mean a OR / XOR condition (FIELD 1 OR FIELD2 / FIELD1 XOR FIELD 2)?
I mean something like this:
SETFILTER (Field1, Condition AND Fiel2, Conditon2);
I need to filter records only if the 2 conditions are TRUE at the same time.
is what you need. It is making AND between these conditions on two fields - it means both must be True... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Take a look at the first and second line.
Don't forget the 2nd parameter of setfilter is a TEXT Condition (Read also the C/AL Online help).
If you only need Field1 = Value 1 then you can also use:
setrange(Field1,ConditionValue);
setrange(field2,Condition2Value);
If you need a Condition for field 1 like 'Bla' Or 'Blup' or 'BlupBlup' Then u use setfilter like
SETFILTER (Field1,'%1|%2|%3','BLA','BLUP','BLUPBLUP'); //<-- in this example, Field 1 is a codefield
Or do you need the records where the value in Field 1 is the value of field 2??
Regards
Thanks for the answers but none of the solutions provided solved my problem.
I've been looking in the Help Menu for functions that can solve my issue, and i think the MARK Function can, but I need some help to put this working!!!
What I realy need to do is to MARK a record and then show only the Marked Records.
My problem now is, I can mark the records, but the MARKEDONLY Function is not working properly.
I'm using the MARK function on the OnAfterGetRecord Trigger and it seems to be working OK because the correct records are selected, but no mater where I put the MARKEDONLY Function, it shows me all the records or none records...
In wich trigger should I put the code? Are there other functions to do the create the desired output?
Thanks
REPEAT
MARK(NOT(("Dimension Value Type" = "Dimension Value Type"::Standard) AND (Blocked = TRUE)));
UNTIL
NEXT = 0;
MARKEDONLY(TRUE);
Problem Solved!!!!
Tank you very much!
You can also just do this as well (on the same trigger):
SETFILTER("Dimension Value Type", '<> %1', "Dimension Value Type"::Standard);
SETRANGE(Blocked, FALSE);
The benefit of this method would be that you wouldn't have to iterate through each record and so, it may be faster.