Hi Everyone,
I have created one new field 'VAT Amount' in purchase line table. and i want this to update as calculated field as:
VAT Amount= Amount including VAT - Amount; eg. VAT Amount=15-10=5;[field: 'Amount including VAT' and 'Amount' already is present]
SO, i tried the below code in VAT Amount field ONValidate trigger in Purchase line table, but its not updating the field.
VAT Amount - OnValidate()
PurchLine2.RESET;
PurchLine2.FINDSET;
REPEAT
PurchLine2.INIT;
VatAmount := PurchLine2."Amount Including VAT" -PurchLine2.Amount;
PurchLine2.VALIDATE("VAT Amount",VatAmount);
PurchLine2.MODIFY;
UNTIL PurchLine2.NEXT= 0;
Will you please guide me,what i am doing wrong.
Thanks,
Mani.
0
Answers
Please guide me for above query. it will be very useful for me.
[As field: 'Amount including VAT' and 'Amount' is normal decimal, and my new field 'VAT Amount' is also normal decimal]
Thanks,
Mani.
Please: indent the code with 2-3 spaces between REPEAT / UNTIL. For execution this will not be necessary, but the code becomes 100 times easier to read.
The PurchLine2.INIT will manipulate your REPEAT / UNTIL loop.
My first conclusion: this code does not make good sense. If you only want to fill your new field, you do not need the loop, but you can calculate your field with:
VatAmount := "Amount Including VAT" - Amount;
The modify will be done automatically by the system.
Thank you for your guidelines.
Actually I was adding that field in table to drag in page. so, i wrote the code in page OnAfter get record() trigger, its working fine now.
"Vat Amount" := "Amount Including VAT" - Amount;
Rec.Modify;
Thanks,
Mani.