Hi,
I would like to copy the filterfields of a dataitem in a report to another dataitem in order to prevent users having to insert the same filter multiple times for each dataitem.
I've tried to use COPYFILTERS, but that's not possible, because I have different records. The error-message indicated that I had to copy the filters one by one.
My problem is that I don't know what filterfields will be filled by the user. I also don't know how many filterfields will be entered.
Is it possible to "loop" through all the filters, and copy them one by one? :-k
0
Comments
You might be able to do something with RecordRef and FieldRef, but then copying one by one is easier.
But I'm not that experienced in programming C/AL.
How can I copy the filters one by one, if I don't know the fieldnames of the filters in advance? I also don't know how many filters there will be... :?
Rec2.Field1.SETFILTER(Rec1.Field1.GETFILTER);
:shock:
And then for all fields.....
unfortunately, I fear there is indeed no other option.
Thanks for the solution!
RecRef.GETTABLE("Table1");
RecRef.SETVIEW("Table2".GETVIEW);
"Table1".SETVIEW(RecRef.GETVIEW);
In the case where I used it table2 is almost a copy from table1.
Yes, this can work if the tables are (almost) identical, just keep in mind that the keys(sorting) are also in the view.
[/code]
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I need to do this also. I can't figure out how to do it with a "fieldreference".
I would really appreciate some sample code.
Sorry it took so long, but I was very busy and hadn't time to see emails with replies.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I'm trying to use this piece of code since I have the same issue. However I don't understand what some of the variables should be set as. (ie what is recField,rerFrom...?)
Appreciate any help.
Dneal
rerFrom,rerTo : recordreference
recField : record variable of table Field
firFrom,firTo : fieldreference
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I"m confused on what this code is doing exactly. I thought it was going to loop through all fields in one table and look for filters and put it in the second table.
But when I look at this I'm assuming I need to fill in the fields myself from each field to each field. Am I missing something? My apologies, I'm not that advanced with Nav programming. :?
Dneal
I hope this makes it clearer.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
This is what I have done:
Thanks again for helping me.
Dneal
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Also once I get it to run the filters are not being copied.
These are my dataitems.
DataItem Name
Customer <Customer>
Sales Header <Sales Header>
Sales Line <Sales Line>
Sales Invoice Header <Sales Invoice Header>
Sales Invoice Line <Sales Invoice Line>
I have put the code in the onaftergetrecord of the Sales Invoice Line and then tried it on the OnPreReport. But when I debug I'm not getting the results. When it's in the OnPreReport it just copies blanks. When it's on the OnAfterGetRecord it just sets the fields. Have I put it in the right place? Perhaps this is more advanced then I'm capable of doing.
Dneal
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!