I've written this trigger, but there's an error that I can't resolve
The Trigger:
trigger AmounTtoWords on Receipt__c (before insert, before update) {
for (Receipt__c **:** Trigger.new) {
if (Total_Amount_Due__c != null && Total_Amount_Due__c >= 0) {
Long n = c.Amount.longValue();
string amo = ConvertCurrencyToWords.english_number(n);
string amo1 = amo.remove(',');
c.Amount_in_Words__c = amo1;
} else {
c.Amount_in_Words__c = null;
}
}
}
The Error:
for (Receipt__c receipt : Trigger.new)
then use that to access the various field values likereceipt.Total_Amount_Due__c
etc. You also reference an undeclared variablec
in some of this code.Total_Amount_Due__c
without variable, so if you name yourReceipt__c
, for example,Receipt__c receipt
, then you should reference to the field asreceipt.Total_Amount_Due__c
.