code to assign certain amount to credit limit base on certain condition

Hi,

Please, i wrote a code to assign a certain value to credit limit base on certain condition but it gave me defferent thing. It is assigning the same amount to all the Customer disregarding the condition. Please do check below .

Thanks

Gbenga

Customer.SETRANGE(Customer.“No.”, Customer.“No.”);
IF Customer.FINDFIRST THEN BEGIN
IF ((Customer.“Balance (LCY)” = 0) AND (Customer.“Credit Limit (LCY)” = 0)) THEN BEGIN
Customer.“Credit Limit (LCY)” := 100000;
Customer.MODIFY
END
ELSE
CurrReport.SKIP;
END;

I would prefer doing it using a processing only report:

Use “Customer” as data item

and on aftergetrecord trigger write the following code:

IF ((Customer.“Balance (LCY)” = 0) AND (Customer.“Credit Limit (LCY)” = 0)) THEN BEGIN
Customer.“Credit Limit (LCY)” := 100000;
Customer.MODIFY
END

And on PostReport trigger write a message informing you completion of report.

Hi,

Thanks for your reply but no modification was done on the credit limit. Is there any other suggestion.

Thanks

Gbenga

Hello

As Balance (LCY) is a flow field, so Use Customer.CALCFIELDS(“Balance (LCY)”); before the earlier code

Hello,

It is still not working, Please is there any way out or am i doing some thing wrong.

Thanks

Gbenga

Hi Gbenga,

Can you post your amended code?

Customer.CALCFIELDS(Customer.“Balance (LCY)”);
IF((Customer.“Balance (LCY)”=0) AND (Customer.“Credit Amount (LCY)”=0))THEN BEGIN
Customer.“Credit Amount (LCY)”:=100000;
Customer.MODIFY
END

Are you using this code in processing only report which has Customer table as dataitem and the code is written on AfterGetRecord trigger?

then it should work…

Export your object as text file and paste here, then we can help you out…