• Class slaesforce
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 12
    Replies
trigger Account on Account (after update) {
set<id> fire =new set<id>();
for(Account hg:trigger.new){
    if(hg.BillingStreet !=trigger.oldMap.get(hg.id)||hg.BillingCity!=trigger.oldMap.get(hg.id)||hg.BillingState/Province!=trigger.get(hg.id)||hg.BillingZip/PostalCode!=trigger.oldMap.get(hg.id)){
        fire.add(hg.id);
}
}
list<contact> cnt;
if(fire.size()>0){
  cnt=[SELECT name,AccountId FROM Contact where AccountId in:fire];
  }
  if(cnt!=null){
list<Contact>contr=new list<contact>();
for(contact von:cnt){
     von.otherStreet=trigger.newMap.get(von.id).BillingStreet;
     von.otherStreet=trigger.newMap.get(von.id).BillingCity;
     von.otherStreet=trigger.newMap.get(von.id).BillingState/Province;
     von.otherStreet=trigger.newMap.get(von.id).BillingZip/PostalCode;
     contr.add(von.id);
 }
 if(contr.size()>0){
 update.contr;
 }
 }
 }
trigger EmployeeInformation on Employe_Infrmation__c (before insert,before update) {

    set<string> gh=new set<string>();
      
    for(Employe_Infrmation__c hh:trigger.new){
    
    if(trigger.IsInsert||(trigger.IsUpdate && hh.Name!=trigger.oldMap.get(hh.Id).Name))
    
    gh.add(hh.Name);
    
}

    set<string> jh =new set <string>();
    
    for(Employe_Infrmation__c hh:[select Name from Employe_Infrmation__c where Name in:gh]){
    
    jh.add(hh.Name);
  }
  
  
  for(Employe_Infrmation__c hh:trigger.new){
  
  if(trigger.IsInsert||(trigger.IsUpdate && hh.Name!=trigger.oldMap.get(hh.Id).Name)){
  
  if(jh.contains(hh.Name))
  
  hh.adderror('Duplicate values');
  }
  }
  }
trigger EmployeInfrmationTrigger on Employe_Infrmation__c (before insert, before update) {
    
    set<string> nam = new set<string>();
    
        for(Employe_Infrmation__c somt:trigger.new){
        
            
    nam.add(somt.Name);
}

    set<string> ch =new set<string>(); 
    
for(Employe_Infrmation__c gh:[select id,Name from Employe_Infrmation__c where Name in id:nam]){

    ch.add(gh.Name);
}

    for(Employe_Infrmation__c somt:trigger.new){
     
     if(somt.Name!=trigger.oldMap.get(somt.id).Name){
            
    if(ch.contains(somt.id))
    
    somt.adderror('kkkk');
    
    }
    }
    }
trigger EmployeeInformationTrigger on Employe_Infrmation__c (before delete) {
        
            Map<Id,Employe_Infrmation__c> naMap = new Map<Id,Employe_Infrmation__c>([SELECT Id,DepartMt__r.Id FROM 
                
                Employe_Infrmation__c where Id in:trigger.oldMap.keyset()]);
        
                     for(Employe_Infrmation__c se:trigger.old){
                     
                     if (naMap.get(se.Id).DepartMt__r.Id.size()>0)
                     
                     se.addError('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj');
                     }
trigger EmployeeInformation on Employe_Infrmation__c (before insert,before update) {

    set<string> gh=new set<string>();
      
    for(Employe_Infrmation__c hh:trigger.new){
    
    if(trigger.IsInsert||(trigger.IsUpdate && hh.Name!=trigger.oldMap.get(hh.Id).Name))
    
    gh.add(hh.Name);
    
}

    set<string> jh =new set <string>();
    
    for(Employe_Infrmation__c hh:[select Name from Employe_Infrmation__c where Name in:gh]){
    
    jh.add(hh.Name);
  }
  
  
  for(Employe_Infrmation__c hh:trigger.new){
  
  if(trigger.IsInsert||(trigger.IsUpdate && hh.Name!=trigger.oldMap.get(hh.Id).Name)){
  
  if(jh.contains(hh.Name))
  
  hh.adderror('Duplicate values');
  }
  }
  }
trigger EmployeeInformationTrigger on Employe_Infrmation__c (before delete) {
        
            Map<Id,Employe_Infrmation__c> naMap = new Map<Id,Employe_Infrmation__c>([SELECT Id,DepartMt__r.Id FROM 
                
                Employe_Infrmation__c where Id in:trigger.oldMap.keyset()]);
        
                     for(Employe_Infrmation__c se:trigger.old){
                     
                     if (naMap.get(se.Id).DepartMt__r.Id.size()>0)
                     
                     se.addError('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj');
                     }
how to pull the custom setting records in to string 
  • November 21, 2015
  • Like
  • 0

Would someone be able to help me write a trigger so that when an account address and phone number change, the address and phone number on all contacts change?  In my perfect world, the phone number would only change on the contact IF before the update they were the same number.  Since I am not a code writer other than when I have to be, I am not sure that is even possible.

 

 

Thanks!

  • August 23, 2012
  • Like
  • 0