When customer balance change

Hi,

I have to export customer balances on a daily basis, but only the customers with a changed balance since the last export. I tried the trigger ONINSERT in the Cust Ledger Entry, but for some reason, the trigger wont fire.

Can anyone guide me in the right direction here :slight_smile:

It’s on a NAV 2009 R2

Regards

Jens

Hello,
Create a new field in Customer Card. BalanceField.
Everytime the report runs compare Balance with BalanceField. If different insert new Balance and Output the report.

It’s easier. . .

The changes in Cust Ledger Entry are controlled by a codeunit which is placed in the on modifiy trigger of the table.

best regards,

Hi Thomas,

Thank you for your reply. I’m almost there :slight_smile:
I have created a field on the Customer table called: BalanceField
Thing is, i have to do this from a code unit, and i have made the following

Customer.SETFILTER(Customer.Balance, ‘<>%1’,Customer.BalanceField);
IF Customer.FINDSET(TRUE, FALSE) THEN
BEGIN

REPEAT
// Do some export stuff here
Customer.CALCFIELDS(Balance);
Customer.BalanceField := Customer.Balance;
Customer.MODIFY;
UNTIL Customer.NEXT = 0;
END;

Seems like i’m having issues with the SETFILTER command. Cause it always find customers with a balance, and not where it differs from the balancefield.

Best regards
Jens

Hello,

Have you done the CALCFIELDS before?

Customer.CALCFIELDS(Balance);
Customer.SETFILTER(Customer.Balance, ‘<>%1’,Customer.BalanceField);
IF Customer.FINDSET(TRUE, FALSE) THEN
BEGIN

REPEAT
// Do some export stuff here
Customer.CALCFIELDS(Balance);
Customer.BalanceField := Customer.Balance;
Customer.MODIFY;
UNTIL Customer.NEXT = 0;
END;

best regards,

Sorry, forgot to mention. This type won’t work. You have to loop thru it to get it working.
Customer.SETFILTER(Customer.Balance, ‘<>%1’,Customer.BalanceField);
It’s not clear what the Customer.BalanceField is in this code. Loop thru records and at the end of every loop do a Customer.RESET.

best regards,

Hi Thomas,

Thanks, that helped a lot. :slight_smile:

I now search through all customers, testing if the balance has changed.

Best regards
Jens