0

I am working on a TriggerHandler and I am pretty new to Apex. Below is my code. I am trying to declare a variable 'cl' for an object createCreditNoteLine and to use a map. Can anyone take a look at the blow and assist me with declaring the variable.

Apex //Map of String and Credit Note Line

    Map<String, blng__CreditNoteLine__c> myMap = new Map<String, blng__CreditNoteLine__c>();                                                            
    for(blng__CreditNoteLine__c : cl) {
            if(Trigger.isAfter && Trigger.isInsert){
                System.debug('creating new Credit Note Line');
                createCreditNoteLine(cl);
            } else {
                System.debug('Updating existing Credit Note Line');
                updateCreditNoteLine(cl);
            }
        }
    }
if(creditNoteLinesToUpsert.size() > 0) {
        System.debug('creditNoteLinesToUpsert: ' + creditNoteLinesToUpsert);
        upsert creditNoteLinesToUpsert;
  • What is the cl variable supposed to hold? – CommonCoreTawan Jul 30 '19 at 18:34
  • is this a separate class/method and if so, are you passing Trigger.new to it and if yes, into what variable? – cropredy Jul 30 '19 at 22:24
  • It is a triggerhandler class that extends a trigger class. The variable should be for a single credit note line. – Jwaldon Jul 30 '19 at 23:29
  • 1
    please use edit to show the trigger calling the method and the method definition in the trigger handler – cropredy Jul 31 '19 at 3:47
0

Assuming you are iterating the map values. You have to put a name for the for left statement:

for(blng__CreditNoteLine__c cl : myMap.values()) {
        if(Trigger.isAfter && Trigger.isInsert){
            System.debug('creating new Credit Note Line');
            createCreditNoteLine(cl);
        } else {
            System.debug('Updating existing Credit Note Line');
            updateCreditNoteLine(cl);
        }
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.