• pradeep m 27
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
trigger accountTestTrggr on Account (before insert, before update){
     for(Account a: Trigger.new){
List<Contact> contacts = [select id, department, firstname, lastname, email from Contact where accountId = :a.Id];
                       
           
     for(Contact c: contacts){
          System.debug(Contact Id[' + c.Id + '], FirstName[' + c.firstname + '],LastName[' + c.lastname +']);                                
         c.Description=c.department+ ' ' + c.firstName + ' ' + c.lastname;               
         update c;
     }      
      }
trigger oppLineTrigger on OpportunityLineItem (before insert) {
Set<Id> pbeIds = new Set<Id>();
  for (OpportunityLineItem oli : Trigger.new)
  pbeIds.add(oli.pricebookentryid);
Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>(
  [select Product2.color__c from PricebookEntry where id in :pbeIds]);
  for (OpportunityLineItem oli : Trigger.new)
  oli.color__c = entries.get(oli.pricebookEntryId).product2.color__c;
}

trigger StudentIdnew on Account (Before Insert) { 

 map<Account,Account Number> map1=trigger.newmap;

for(Account a : map1.values){

if(a.AccountNumber == null){
          a.AccountNumber = '12345';
         
          }     
           
 }
}