SETFILTER not working correctly after a CALCFIELDS

CCTNAVCCTNAV Member Posts: 8
Nav5

Lets say I wanted to filter according to Fund on the GL Account Table. I then wanted to recalc the flowfields (Debit, Credit) that I want to show on my report and then filter out any lines that are zeroed out from the filter.

My code is pretty much:
"G/L Account".SETFILTER("Fund Filter", FundVal);
"G/L Account".CALCFIELDS("Debit Amount", "Credit Amount", "Actual");
"G/L Account".SETFILTER("Actual", '<>0');

For some reason its returning the correct set but the first record is always the first entry in the table. One that has a value of Actual = 0. I have tested this with a message. Any ideas?

EDIT:

I have it located in the Data Item Body - OnPreSelection() Trigger

Comments

  • garakgarak Member Posts: 3,263
    edited 2010-04-14
    To use calcfields, u must get a record before. The calcfields on OnPreDatItem has no function.

    If u set the the filter in OnPreDataItem for your flowfield, the report will calculate the values self.
    So you doesn't need the calcfields (native and SQL).
    Also is the calcformula of "Actual" based on the "Fund" field?

    You can test it with a very simple report. New blank Report -> DataItem 15 -> G/L Account - OnPreDataItem() -> setfilter("Debit amount",'<>%1',0);
    -> In the Bodysection a control with the "No."

    Now, only Recs with a Debit Amount <> 0 will be showed.

    regards
    Do you make it right, it works too!
  • CCTNAVCCTNAV Member Posts: 8
    garak wrote:
    To use calcfields, u must get a record before. the calcfields on OnPre has no function.

    So, set the calcfields on OnAfterGetRecord and skip then the record if the Actual is zero.
    Also is the calcformula of "Actual" based on the "Fund" field?


    regards

    ](*,)

    Thanks. I moved the filtering to the Data Item PreDataItem and now it works fine.
  • garakgarak Member Posts: 3,263
    ahh now i see u use Body - OnPreSelection().... <- that is also the mistake

    Regards
    Do you make it right, it works too!
  • garakgarak Member Posts: 3,263
    oh, you're faster....

    You are welcome
    Do you make it right, it works too!
Sign In or Register to comment.