Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger invoiceAccountInsert on invoice__c (before insert) {
- Set<String> accountNames = new Set<String>();
- Map<String, Id> accountNameToId = new Map<String, Id>();
- for(invoice__c record: Trigger.new) {
- accountNames.add(record.Account__c);
- System.debug('Account__c >>>>>>' + record.Account__c);
- }
- list<Account> acclist = new list<Account>();
- acclist = [SELECT Id, Name FROM Account WHERE Name IN :accountNames];
- for(Account acc:acclist)
- {
- accountNameToId.put(acc.Name, acc.Id);
- System.debug('acc.Name >>>>>>' + acc.Name);
- System.debug('acc.Id >>>>>>' + acc.Id);
- System.debug('accountNameToId >>>>>>' + accountNameToId);
- insert acc;
- }
- }
Add Comment
Please, Sign In to add comment