You need to sign in to do that
Don't have an account?

in this code insert is working update is not working please suggest me a small thing is missing
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');
}
}
}
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');
}
}
}
sorry fo dealy respond some little bussy ...thanks for suggestion...
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;
}
}
}
ERROR WILL COME:----thats rror: Compile Error: Variable does not exist: Province at line 4 column 113
contr.add(von); that one
set<Id> fire =new set<Id>();
for(Account hg:trigger.new){
if(hg.BillingStreet != trigger.oldMap.get(hg.Id).BillingStreet || hg.BillingCity != trigger.oldMap.get(hg.Id).BillingCity || hg.BillingState != trigger.oldMap.get(hg.Id).BillingState || hg.BillingPostalCode != trigger.oldMap.get(hg.Id).BillingPostalCode || hg.BillingCountry != trigger.oldMap.get(hg.Id).BillingCountry) {
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.otherCity=trigger.newMap.get(von.Id).BillingCity;
von.otherState=trigger.newMap.get(von.Id).BillingState;
von.otherpostalCode=trigger.newMap.get(von.Id).BillingPostalCode;
von.othercountry=trigger.newMap.get(von.Id).BillingCountry;
contr.add(von);
}
if(contr.size()>0){
update contr;
}
}
}